@@ -20,14 +20,12 @@ object AugmentScala2Traits {
20
20
val name : String = " augmentScala2Traits"
21
21
}
22
22
23
- /** This phase augments Scala2 traits with additional members needed for mixin composition .
23
+ /** This phase augments Scala2 traits to fix up super accessors .
24
24
*
25
- * These symbols would have been added between Unpickling and Mixin in the Scala2 pipeline.
25
+ * Strangely, Scala 2 super accessors are pickled as private, but are compiled as public expanded.
26
+ * In this phase we expand them and make them non-private, so that `ResolveSuper` does something meaningful.
26
27
*
27
- * Specifically, we:
28
- * - Add trait setters for vals defined in traits.
29
- * - Expand the names of all private getters and setters as well as super accessors in the trait and make
30
- * not-private.
28
+ * TODO Should we merge this into `ResolveSuper` at this point?
31
29
*/
32
30
class AugmentScala2Traits extends MiniPhase with IdentityDenotTransformer { thisPhase =>
33
31
import ast .tpd ._
@@ -47,21 +45,8 @@ class AugmentScala2Traits extends MiniPhase with IdentityDenotTransformer { this
47
45
}
48
46
49
47
private def augmentScala2Trait (mixin : ClassSymbol )(implicit ctx : Context ): Unit = {
50
- def traitSetter (getter : TermSymbol ) =
51
- getter.copy(
52
- name = getter.ensureNotPrivate.name
53
- .expandedName(getter.owner, TraitSetterName )
54
- .asTermName.setterName,
55
- flags = Method | Accessor ,
56
- info = MethodType (getter.info.resultType :: Nil , defn.UnitType ))
57
-
58
48
for (sym <- mixin.info.decls) {
59
- if (sym.isGetter && ! sym.isOneOf(DeferredOrLazy ) && ! sym.setter.exists &&
60
- ! sym.info.resultType.isInstanceOf [ConstantType ])
61
- traitSetter(sym.asTerm).enteredAfter(thisPhase)
62
- if ((sym.isAllOf(PrivateAccessor ) && ! sym.name.is(ExpandedName ) &&
63
- (sym.isGetter || sym.isSetter)) // strangely, Scala 2 fields are also methods that have Accessor set.
64
- || sym.isSuperAccessor) // scala2 superaccessors are pickled as private, but are compiled as public expanded
49
+ if (sym.isSuperAccessor)
65
50
sym.ensureNotPrivate.installAfter(thisPhase)
66
51
}
67
52
mixin.setFlagFrom(thisPhase, Scala2xPartiallyAugmented )
0 commit comments