diff options
author | Dmitry Petrashko <dark@d-d.me> | 2016-05-04 12:35:31 +0200 |
---|---|---|
committer | Dmitry Petrashko <dark@d-d.me> | 2016-05-04 12:35:31 +0200 |
commit | 04993c7ec132b47e4241b7a89221d83c202dd95c (patch) | |
tree | 79c2807cf431aae97dd615ce3aa040bbb94c8a0c | |
parent | f9858a402db9a38ac0beae8bb30a36e7656386aa (diff) | |
parent | 0900f1195b22b4a3551841e1e449fcedc752ed03 (diff) | |
download | dotty-04993c7ec132b47e4241b7a89221d83c202dd95c.tar.gz dotty-04993c7ec132b47e4241b7a89221d83c202dd95c.tar.bz2 dotty-04993c7ec132b47e4241b7a89221d83c202dd95c.zip |
Merge pull request #1245 from dotty-staging/elimself
eliminate self symbol in Template and ClassInfo
-rw-r--r-- | src/dotty/tools/dotc/transform/FirstTransform.scala | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/transform/FirstTransform.scala b/src/dotty/tools/dotc/transform/FirstTransform.scala index 97dd9404f..ae72d5f6c 100644 --- a/src/dotty/tools/dotc/transform/FirstTransform.scala +++ b/src/dotty/tools/dotc/transform/FirstTransform.scala @@ -28,6 +28,7 @@ import StdNames._ * - ensures there are companion objects for all classes except module classes * - eliminates some kinds of trees: Imports, NamedArgs * - stubs out native methods + * - eliminate self tree in Template and self symbol in ClassInfo */ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer with AnnotationTransformer { thisTransformer => import ast.tpd._ @@ -44,7 +45,14 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi this } - def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp/*{ + /** eliminate self symbol in ClassInfo */ + def transformInfo(tp: Type, sym: Symbol)(implicit ctx: Context): Type = tp match { + case tp@ClassInfo(_, _, _, _, self: Symbol) => + tp.derivedClassInfo(selfInfo = self.info) + case _ => + tp + } + /* tp match { //create companions for value classes that are not from currently compiled source file case tp@ClassInfo(_, cls, _, decls, _) @@ -59,7 +67,8 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi case _ => tp } } -*/ + */ + override def checkPostCondition(tree: Tree)(implicit ctx: Context): Unit = { tree match { case Select(qual, _) if tree.symbol.exists => @@ -132,6 +141,11 @@ class FirstTransform extends MiniPhaseTransform with IdentityDenotTransformer wi (modul, mcComp, classComp) } + /** elimiate self in Template */ + override def transformTemplate(impl: Template)(implicit ctx: Context, info: TransformerInfo): Tree = { + cpy.Template(impl)(self = EmptyValDef) + } + override def transformDefDef(ddef: DefDef)(implicit ctx: Context, info: TransformerInfo) = { if (ddef.symbol.hasAnnotation(defn.NativeAnnot)) { ddef.symbol.resetFlag(Deferred) |