@@ -20,14 +20,12 @@ object AugmentScala2Traits {
2020 val name : String = " augmentScala2Traits"
2121}
2222
23- /** This phase augments Scala2 traits with additional members needed for mixin composition .
23+ /** This phase augments Scala2 traits to fix up super accessors .
2424 *
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.
2627 *
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?
3129 */
3230class AugmentScala2Traits extends MiniPhase with IdentityDenotTransformer { thisPhase =>
3331 import ast .tpd ._
@@ -47,21 +45,8 @@ class AugmentScala2Traits extends MiniPhase with IdentityDenotTransformer { this
4745 }
4846
4947 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-
5848 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)
6550 sym.ensureNotPrivate.installAfter(thisPhase)
6651 }
6752 mixin.setFlagFrom(thisPhase, Scala2xPartiallyAugmented )
0 commit comments