File tree 2 files changed +10
-2
lines changed
compiler/src/dotty/tools/dotc/typer
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 =>
1043
1043
def isInline = sym.is(FinalOrInline , butNot = Method | Mutable )
1044
1044
1045
1045
// 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.
1047
1048
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
1049
1051
case _ => ctx.harmonizeUnion(tp.widen)
1050
1052
}
1051
1053
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