@@ -28,6 +28,7 @@ import StdNames._
28
28
* - ensures there are companion objects for all classes except module classes
29
29
* - eliminates some kinds of trees: Imports, NamedArgs
30
30
* - stubs out native methods
31
+ * - eliminate self tree in Template and self symbol in ClassInfo
31
32
*/
32
33
class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer with AnnotationTransformer { thisTransformer =>
33
34
import ast .tpd ._
@@ -44,7 +45,14 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
44
45
this
45
46
}
46
47
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
+ /*
48
56
tp match {
49
57
//create companions for value classes that are not from currently compiled source file
50
58
case tp@ClassInfo(_, cls, _, decls, _)
@@ -59,7 +67,8 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
59
67
case _ => tp
60
68
}
61
69
}
62
- */
70
+ */
71
+
63
72
override def checkPostCondition (tree : Tree )(implicit ctx : Context ): Unit = {
64
73
tree match {
65
74
case Select (qual, _) if tree.symbol.exists =>
@@ -132,6 +141,11 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi
132
141
(modul, mcComp, classComp)
133
142
}
134
143
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
+
135
149
override def transformDefDef (ddef : DefDef )(implicit ctx : Context , info : TransformerInfo ) = {
136
150
if (ddef.symbol.hasAnnotation(defn.NativeAnnot )) {
137
151
ddef.symbol.resetFlag(Deferred )
0 commit comments