diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index 342061d48471..6f5f70117a1b 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1115,15 +1115,10 @@ class Namer { typer: Typer => WildcardType } getOrElse WildcardType - // println(s"final inherited for $sym: ${inherited.toString}") !!! - // println(s"owner = ${sym.owner}, decls = ${sym.owner.info.decls.show}") - def isInline = sym.is(FinalOrInlineOrTransparent, butNot = Method | Mutable) - - // Widen rhs type and eliminate `|' but keep ConstantTypes if - // definition is inline (i.e. final in Scala2) and keep module singleton types - // instead of widening to the underlying module class types. + // Widen rhs type and eliminate `|' but keep ConstantTypes and module singleton + // types instead of widening to the underlying module class types. def widenRhs(tp: Type): Type = tp.widenTermRefExpr match { - case ctp: ConstantType if isInline => ctp + case ctp: ConstantType if !sym.is(Method | Mutable) => ctp case ref: TypeRef if ref.symbol.is(ModuleClass) => tp case _ => tp.widen.widenUnion } diff --git a/tests/run/i4559.scala b/tests/run/i4559.scala index d9b5cb2d8c8a..cae0493b42a2 100644 --- a/tests/run/i4559.scala +++ b/tests/run/i4559.scala @@ -1,6 +1,6 @@ trait A { println(s"super[A] init") - lazy val x = { println("super[A].x()"); 123 } + lazy val x: Int = { println("super[A].x()"); 123 } } class B extends A {