diff options
author | Martin Odersky <odersky@gmail.com> | 2016-09-21 19:15:27 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-09-21 19:15:27 +0200 |
commit | c9d670f4ce41662215799a728b145c6a2f6ab826 (patch) | |
tree | 0a0f5e4380b55007d6c769a0190755faf7751455 | |
parent | 7062b90eec9f63aef9023401ea8ca0acd524e0d6 (diff) | |
download | dotty-c9d670f4ce41662215799a728b145c6a2f6ab826.tar.gz dotty-c9d670f4ce41662215799a728b145c6a2f6ab826.tar.bz2 dotty-c9d670f4ce41662215799a728b145c6a2f6ab826.zip |
Fix CollectSuper
Add comment what it is supposed to achieve and change the implementation
to follow the comment.
-rw-r--r-- | src/dotty/tools/backend/jvm/CollectSuperCalls.scala | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/dotty/tools/backend/jvm/CollectSuperCalls.scala b/src/dotty/tools/backend/jvm/CollectSuperCalls.scala index e504047f3..8285bfe4b 100644 --- a/src/dotty/tools/backend/jvm/CollectSuperCalls.scala +++ b/src/dotty/tools/backend/jvm/CollectSuperCalls.scala @@ -4,9 +4,13 @@ import dotty.tools.dotc.ast.tpd import dotty.tools.dotc.ast.Trees._ import dotty.tools.dotc.core.Contexts.Context import dotty.tools.dotc.core.Symbols._ +import dotty.tools.dotc.core.Flags.Trait import dotty.tools.dotc.transform.TreeTransforms.{MiniPhaseTransform, TransformerInfo} -/** Collect all super calls except to the parent class. +/** Collect all super calls to trait members. + * + * For each super reference to trait member, register a call from the current class to the + * owner of the referenced member. * * This information is used to know if it is safe to remove a redundant mixin class. * A redundant mixin class is one that is implemented by another mixin class. As the @@ -20,12 +24,9 @@ class CollectSuperCalls extends MiniPhaseTransform { override def transformSelect(tree: Select)(implicit ctx: Context, info: TransformerInfo): Tree = { tree.qualifier match { - case Super(qual, mix) if mix.nonEmpty => - val classSymbol: ClassSymbol = qual match { - case qual: This => qual.symbol.asClass.classSymbol - case qual => qual.symbol.info.classSymbol.asClass - } - registerSuperCall(classSymbol, tree.symbol.owner.asClass) + case sup: Super => + if (tree.symbol.owner.is(Trait)) + registerSuperCall(ctx.owner.enclosingClass.asClass, tree.symbol.owner.asClass) case _ => } tree |