From c9d670f4ce41662215799a728b145c6a2f6ab826 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 21 Sep 2016 19:15:27 +0200 Subject: Fix CollectSuper Add comment what it is supposed to achieve and change the implementation to follow the comment. --- src/dotty/tools/backend/jvm/CollectSuperCalls.scala | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/dotty/tools/backend/jvm/CollectSuperCalls.scala') 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 -- cgit v1.2.3