Skip to content

Commit 62b756b

Browse files
committed
Simplify in widenRHS
When computing the type for local type inferennce, use a simplify transformation.
1 parent 947c49e commit 62b756b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2891,6 +2891,7 @@ object Types {
28912891
else apply(tp1, tp2)
28922892
}
28932893

2894+
/** An extractor for `T | Null` or `Null | T`, returning the `T` */
28942895
object OrNull with
28952896
private def stripNull(tp: Type)(given Context): Type = tp match
28962897
case tp @ OrType(tp1, tp2) =>

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,11 +1347,10 @@ class Namer { typer: Typer =>
13471347
// We also drop the @Repeated annotation here to avoid leaking it in method result types
13481348
// (see run/inferred-repeated-result).
13491349
def widenRhs(tp: Type): Type = {
1350-
val tp1 = tp.widenTermRefExpr match {
1350+
val tp1 = tp.widenTermRefExpr.simplified match
13511351
case ctp: ConstantType if isInlineVal => ctp
13521352
case ref: TypeRef if ref.symbol.is(ModuleClass) => tp
1353-
case _ => tp.widenUnion
1354-
}
1353+
case tp => tp.widenUnion
13551354
tp1.dropRepeatedAnnot
13561355
}
13571356

0 commit comments

Comments
 (0)