@@ -4,9 +4,13 @@ import dotty.tools.dotc.ast.tpd
4
4
import dotty .tools .dotc .ast .Trees ._
5
5
import dotty .tools .dotc .core .Contexts .Context
6
6
import dotty .tools .dotc .core .Symbols ._
7
+ import dotty .tools .dotc .core .Flags .Trait
7
8
import dotty .tools .dotc .transform .TreeTransforms .{MiniPhaseTransform , TransformerInfo }
8
9
9
- /** Collect all super calls except to the parent class.
10
+ /** Collect all super calls to trait members.
11
+ *
12
+ * For each super reference to trait member, register a call from the current class to the
13
+ * owner of the referenced member.
10
14
*
11
15
* This information is used to know if it is safe to remove a redundant mixin class.
12
16
* A redundant mixin class is one that is implemented by another mixin class. As the
@@ -20,12 +24,9 @@ class CollectSuperCalls extends MiniPhaseTransform {
20
24
21
25
override def transformSelect (tree : Select )(implicit ctx : Context , info : TransformerInfo ): Tree = {
22
26
tree.qualifier match {
23
- case Super (qual, mix) if mix.nonEmpty =>
24
- val classSymbol : ClassSymbol = qual match {
25
- case qual : This => qual.symbol.asClass.classSymbol
26
- case qual => qual.symbol.info.classSymbol.asClass
27
- }
28
- registerSuperCall(classSymbol, tree.symbol.owner.asClass)
27
+ case sup : Super =>
28
+ if (tree.symbol.owner.is(Trait ))
29
+ registerSuperCall(ctx.owner.enclosingClass.asClass, tree.symbol.owner.asClass)
29
30
case _ =>
30
31
}
31
32
tree
0 commit comments