Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1115,15 +1115,11 @@ 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this comment needs to be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point

// 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
}
Expand Down
2 changes: 1 addition & 1 deletion tests/run/i4559.scala
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down