Skip to content

Commit 9ad85c3

Browse files
committed
Merge pull request #833 from dotty-staging/explicit-outer
Fix bugs in ExplicitOuter
2 parents d19aec7 + 7867f8c commit 9ad85c3

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,19 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf
8484
newDefs += ValDef(outerParamAcc, EmptyTree)
8585
newDefs += DefDef(outerAccessor(cls).asTerm, ref(outerParamAcc))
8686
}
87+
88+
for (parentTrait <- cls.mixins) {
89+
if (needsOuterIfReferenced(parentTrait)) {
90+
val parentTp = cls.denot.thisType.baseTypeRef(parentTrait)
91+
val outerAccImpl = newOuterAccessor(cls, parentTrait).enteredAfter(thisTransformer)
92+
newDefs += DefDef(outerAccImpl, singleton(outerPrefix(parentTp)))
93+
}
94+
}
95+
8796
val parents1 =
8897
for (parent <- impl.parents) yield {
8998
val parentCls = parent.tpe.classSymbol.asClass
9099
if (parentCls.is(Trait)) {
91-
if (needsOuterIfReferenced(parentCls)) {
92-
val outerAccImpl = newOuterAccessor(cls, parentCls).enteredAfter(thisTransformer)
93-
newDefs += DefDef(outerAccImpl, singleton(outerPrefix(parent.tpe)))
94-
}
95100
parent
96101
}
97102
else parent match { // ensure class parent is a constructor
@@ -145,7 +150,7 @@ object ExplicitOuter {
145150

146151
/** A new outer accessor for class `cls` which is a member of `owner` */
147152
private def newOuterAccessor(owner: ClassSymbol, cls: ClassSymbol)(implicit ctx: Context) = {
148-
val deferredIfTrait = if (cls.is(Trait)) Deferred else EmptyFlags
153+
val deferredIfTrait = if (owner.is(Trait)) Deferred else EmptyFlags
149154
val outerAccIfOwn = if (owner == cls) OuterAccessor else EmptyFlags
150155
newOuterSym(owner, cls, outerAccName(cls),
151156
Final | Method | Stable | outerAccIfOwn | deferredIfTrait)

0 commit comments

Comments
 (0)