@@ -17,6 +17,7 @@ import ast.Trees._
17
17
import util .Positions ._
18
18
import Names ._
19
19
import collection .mutable
20
+ import ResolveSuper ._
20
21
21
22
/** This phase adds super accessors and method overrides where
22
23
* linearization differs from Java's rule for default methods in interfaces.
@@ -51,33 +52,6 @@ class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { th
51
52
override def runsAfter = Set (classOf [ElimByName ], // verified empirically, need to figure out what the reason is.
52
53
classOf [AugmentScala2Traits ])
53
54
54
- /** Returns the symbol that is accessed by a super-accessor in a mixin composition.
55
- *
56
- * @param base The class in which everything is mixed together
57
- * @param member The symbol statically referred to by the superaccessor in the trait
58
- */
59
- private def rebindSuper (base : Symbol , acc : Symbol )(implicit ctx : Context ): Symbol = {
60
- var bcs = base.info.baseClasses.dropWhile(acc.owner != _).tail
61
- var sym : Symbol = NoSymbol
62
- val unexpandedAccName =
63
- if (acc.is(ExpandedName )) // Cannot use unexpandedName because of #765. t2183.scala would fail if we did.
64
- acc.name
65
- .drop(acc.name.indexOfSlice(nme.EXPAND_SEPARATOR ++ nme.SUPER_PREFIX ))
66
- .drop(nme.EXPAND_SEPARATOR .length)
67
- else acc.name
68
- val SuperAccessorName (memberName) = unexpandedAccName : Name // dotty deviation: ": Name" needed otherwise pattern type is neither a subtype nor a supertype of selector type
69
- ctx.debuglog(i " starting rebindsuper from $base of ${acc.showLocated}: ${acc.info} in $bcs, name = $memberName" )
70
- while (bcs.nonEmpty && sym == NoSymbol ) {
71
- val other = bcs.head.info.nonPrivateDecl(memberName)
72
- if (ctx.settings.debug.value)
73
- ctx.log(i " rebindsuper ${bcs.head} $other deferred = ${other.symbol.is(Deferred )}" )
74
- sym = other.matchingDenotation(base.thisType, base.thisType.memberInfo(acc)).symbol
75
- bcs = bcs.tail
76
- }
77
- assert(sym.exists)
78
- sym
79
- }
80
-
81
55
override def transformTemplate (impl : Template )(implicit ctx : Context , info : TransformerInfo ) = {
82
56
val cls = impl.symbol.owner.asClass
83
57
val ops = new MixinOps (cls, thisTransform)
@@ -110,3 +84,32 @@ class ResolveSuper extends MiniPhaseTransform with IdentityDenotTransformer { th
110
84
111
85
private val PrivateOrAccessorOrDeferred = Private | Accessor | Deferred
112
86
}
87
+
88
+ object ResolveSuper {
89
+ /** Returns the symbol that is accessed by a super-accessor in a mixin composition.
90
+ *
91
+ * @param base The class in which everything is mixed together
92
+ * @param acc The symbol statically referred to by the superaccessor in the trait
93
+ */
94
+ def rebindSuper (base : Symbol , acc : Symbol )(implicit ctx : Context ): Symbol = {
95
+ var bcs = base.info.baseClasses.dropWhile(acc.owner != _).tail
96
+ var sym : Symbol = NoSymbol
97
+ val unexpandedAccName =
98
+ if (acc.is(ExpandedName )) // Cannot use unexpandedName because of #765. t2183.scala would fail if we did.
99
+ acc.name
100
+ .drop(acc.name.indexOfSlice(nme.EXPAND_SEPARATOR ++ nme.SUPER_PREFIX ))
101
+ .drop(nme.EXPAND_SEPARATOR .length)
102
+ else acc.name
103
+ val SuperAccessorName (memberName) = unexpandedAccName : Name // dotty deviation: ": Name" needed otherwise pattern type is neither a subtype nor a supertype of selector type
104
+ ctx.debuglog(i " starting rebindsuper from $base of ${acc.showLocated}: ${acc.info} in $bcs, name = $memberName" )
105
+ while (bcs.nonEmpty && sym == NoSymbol ) {
106
+ val other = bcs.head.info.nonPrivateDecl(memberName)
107
+ if (ctx.settings.debug.value)
108
+ ctx.log(i " rebindsuper ${bcs.head} $other deferred = ${other.symbol.is(Deferred )}" )
109
+ sym = other.matchingDenotation(base.thisType, base.thisType.memberInfo(acc)).symbol
110
+ bcs = bcs.tail
111
+ }
112
+ assert(sym.exists)
113
+ sym
114
+ }
115
+ }
0 commit comments