File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -1043,9 +1043,11 @@ class Namer { typer: Typer =>
10431043 def isInline = sym.is(FinalOrInline , butNot = Method | Mutable )
10441044
10451045 // Widen rhs type and approximate `|' but keep ConstantTypes if
1046- // definition is inline (i.e. final in Scala2).
1046+ // definition is inline (i.e. final in Scala2) and keep module singleton types
1047+ // instead of widening to the underlying module class types.
10471048 def widenRhs (tp : Type ): Type = tp.widenTermRefExpr match {
1048- case tp : ConstantType if isInline => tp
1049+ case ctp : ConstantType if isInline => ctp
1050+ case ref : TypeRef if ref.symbol.is(ModuleClass ) => tp
10491051 case _ => ctx.harmonizeUnion(tp.widen)
10501052 }
10511053
Original file line number Diff line number Diff line change 1+ object Test {
2+ val nil = scala.collection.immutable.Nil
3+ def f (x : nil.type ): Int = 3
4+
5+ f(scala.collection.immutable.Nil )
6+ }
You can’t perform that action at this time.
0 commit comments