Skip to content

Commit cdab9a1

Browse files
committed
Support overloaded lazy vals coming from Scala2 traits.
1 parent 75d5eee commit cdab9a1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,11 @@ class Mixin extends MiniPhaseTransform with SymTransformer { thisTransform =>
165165
transformFollowing(
166166
DefDef(implementation(getter.asTerm),
167167
if (isScala2x) {
168-
if (getter.is(Flags.Lazy)) // lazy vals need to have a rhs that will be the lazy initializer
169-
ref(mixin.implClass).select(getter.name).appliedTo(This(ctx.owner.asClass))
168+
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.nonPrivateDecl(getter.name).suchThat(_.is(Lazy)).symbol // lazy val can be overloaded
171+
ref(mixin.implClass).select(sym).appliedTo(This(ctx.owner.asClass))
172+
}
170173
else default
171174
} else initial)
172175
)

0 commit comments

Comments
 (0)