From dc1f711e1a362cf0ae7d15e8d19a2ccae7c80946 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 21 Oct 2015 17:22:20 +0200 Subject: [PATCH 1/2] ExplicitOuter: methods in classes should not be deferred. --- src/dotty/tools/dotc/transform/ExplicitOuter.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 0dda44e840dc..3e839326ed9f 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -145,7 +145,7 @@ object ExplicitOuter { /** A new outer accessor for class `cls` which is a member of `owner` */ private def newOuterAccessor(owner: ClassSymbol, cls: ClassSymbol)(implicit ctx: Context) = { - val deferredIfTrait = if (cls.is(Trait)) Deferred else EmptyFlags + val deferredIfTrait = if (owner.is(Trait)) Deferred else EmptyFlags val outerAccIfOwn = if (owner == cls) OuterAccessor else EmptyFlags newOuterSym(owner, cls, outerAccName(cls), Final | Method | Stable | outerAccIfOwn | deferredIfTrait) From 7867f8cc9ff70f0e78acbd8af54f64a073a94f53 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Wed, 21 Oct 2015 17:23:00 +0200 Subject: [PATCH 2/2] ExplicitOuter: fix generation of outer methods for indirectly inherited traits. --- src/dotty/tools/dotc/transform/ExplicitOuter.scala | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/dotty/tools/dotc/transform/ExplicitOuter.scala b/src/dotty/tools/dotc/transform/ExplicitOuter.scala index 3e839326ed9f..7391f3cec85c 100644 --- a/src/dotty/tools/dotc/transform/ExplicitOuter.scala +++ b/src/dotty/tools/dotc/transform/ExplicitOuter.scala @@ -84,14 +84,19 @@ class ExplicitOuter extends MiniPhaseTransform with InfoTransformer { thisTransf newDefs += ValDef(outerParamAcc, EmptyTree) newDefs += DefDef(outerAccessor(cls).asTerm, ref(outerParamAcc)) } + + for (parentTrait <- cls.mixins) { + if (needsOuterIfReferenced(parentTrait)) { + val parentTp = cls.denot.thisType.baseTypeRef(parentTrait) + val outerAccImpl = newOuterAccessor(cls, parentTrait).enteredAfter(thisTransformer) + newDefs += DefDef(outerAccImpl, singleton(outerPrefix(parentTp))) + } + } + val parents1 = for (parent <- impl.parents) yield { val parentCls = parent.tpe.classSymbol.asClass if (parentCls.is(Trait)) { - if (needsOuterIfReferenced(parentCls)) { - val outerAccImpl = newOuterAccessor(cls, parentCls).enteredAfter(thisTransformer) - newDefs += DefDef(outerAccImpl, singleton(outerPrefix(parent.tpe))) - } parent } else parent match { // ensure class parent is a constructor