Skip to content

Commit 797bfd7

Browse files
committed
Scala2 mixin: For some lazy vals inside traits, Lazy flag isn't set on implementation method.
Cannot rely on it. Instead use method signature.
1 parent 0129468 commit 797bfd7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/dotty/tools/dotc/transform/Mixin.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,10 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform =>
166166
DefDef(implementation(getter.asTerm),
167167
if (isScala2x) {
168168
if (getter.is(Flags.Lazy)) { // lazy vals need to have a rhs that will be the lazy initializer
169-
val reciever = ref(mixin.implClass)
170-
val sym = reciever.tpe.widen.nonPrivateDecl(getter.name).suchThat(_.is(Lazy)).symbol // lazy val can be overloaded
169+
val sym = mixin.implClass.info.nonPrivateDecl(getter.name).suchThat(_.info.paramTypess match {
170+
case List(List(t: TypeRef)) => t.isDirectRef(mixin)
171+
case _ => false
172+
}).symbol // lazy val can be overloaded
171173
ref(mixin.implClass).select(sym).appliedTo(This(ctx.owner.asClass))
172174
}
173175
else default

0 commit comments

Comments
 (0)