@@ -28,6 +28,7 @@ import StdNames._
2828 * - ensures there are companion objects for all classes except module classes
2929 * - eliminates some kinds of trees: Imports, NamedArgs
3030 * - stubs out native methods
31+ * - eliminate self tree in Template and self symbol in ClassInfo
3132 */
3233class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer with AnnotationTransformer { thisTransformer =>
3334 import ast .tpd ._
@@ -44,7 +45,14 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
4445 this
4546 }
4647
47- def transformInfo (tp : Type , sym : Symbol )(implicit ctx : Context ): Type = tp/* {
48+ /** eliminate self symbol in ClassInfo */
49+ def transformInfo (tp : Type , sym : Symbol )(implicit ctx : Context ): Type = tp match {
50+ case tp@ ClassInfo (_, _, _, _, self : Symbol ) =>
51+ tp.derivedClassInfo(selfInfo = self.info)
52+ case _ =>
53+ tp
54+ }
55+ /*
4856 tp match {
4957 //create companions for value classes that are not from currently compiled source file
5058 case tp@ClassInfo(_, cls, _, decls, _)
@@ -59,7 +67,8 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
5967 case _ => tp
6068 }
6169 }
62- */
70+ */
71+
6372 override def checkPostCondition (tree : Tree )(implicit ctx : Context ): Unit = {
6473 tree match {
6574 case Select (qual, _) if tree.symbol.exists =>
@@ -132,6 +141,11 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
132141 (modul, mcComp, classComp)
133142 }
134143
144+ /** elimiate self in Template */
145+ override def transformTemplate (impl : Template )(implicit ctx : Context , info : TransformerInfo ): Tree = {
146+ cpy.Template (impl)(self = EmptyValDef )
147+ }
148+
135149 override def transformDefDef (ddef : DefDef )(implicit ctx : Context , info : TransformerInfo ) = {
136150 if (ddef.symbol.hasAnnotation(defn.NativeAnnot )) {
137151 ddef.symbol.resetFlag(Deferred )
0 commit comments