diff options
author | Martin Odersky <odersky@gmail.com> | 2016-10-31 14:46:14 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-10-31 14:46:14 +0100 |
commit | 0c3a6788ababab2ac10c3dbf76cd3c088ff0582c (patch) | |
tree | cb1e1ae1012edd6c61e898086baa61e029af1faa /src/dotty/tools/dotc/transform/PostTyper.scala | |
parent | d4c26fc6072e69d3f58685e6bfec4609eb9af13c (diff) | |
download | dotty-0c3a6788ababab2ac10c3dbf76cd3c088ff0582c.tar.gz dotty-0c3a6788ababab2ac10c3dbf76cd3c088ff0582c.tar.bz2 dotty-0c3a6788ababab2ac10c3dbf76cd3c088ff0582c.zip |
Keep rhs of TypeDefs until pickling
Don't convert to a TypeTree in PostTyper, because that
loses internal positions.
Diffstat (limited to 'src/dotty/tools/dotc/transform/PostTyper.scala')
-rw-r--r-- | src/dotty/tools/dotc/transform/PostTyper.scala | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/src/dotty/tools/dotc/transform/PostTyper.scala b/src/dotty/tools/dotc/transform/PostTyper.scala index 6b9fc084e..49727e70b 100644 --- a/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/src/dotty/tools/dotc/transform/PostTyper.scala @@ -223,26 +223,23 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisTran case tree: TypeDef => transformMemberDef(tree) val sym = tree.symbol - val tree1 = - if (sym.isClass) { - if (sym.owner.is(Package) && - ctx.compilationUnit.source.exists && - sym != defn.SourceFileAnnot) - sym.addAnnotation(Annotation.makeSourceFile(ctx.compilationUnit.source.file.path)) + if (sym.isClass) { + // Add SourceFile annotation to top-level classes + if (sym.owner.is(Package) && + ctx.compilationUnit.source.exists && + sym != defn.SourceFileAnnot) + sym.addAnnotation(Annotation.makeSourceFile(ctx.compilationUnit.source.file.path)) - if (!sym.isAnonymousClass) // ignore anonymous class - for (parent <- sym.asClass.classInfo.classParents) { - val pclazz = parent.classSymbol - if (pclazz.is(Sealed)) pclazz.addAnnotation(Annotation.makeChild(sym)) - } + // Add Child annotation to sealed parents unless current class is anonymous + if (!sym.isAnonymousClass) // ignore anonymous class + for (parent <- sym.asClass.classInfo.classParents) { + val pclazz = parent.classSymbol + if (pclazz.is(Sealed)) pclazz.addAnnotation(Annotation.makeChild(sym)) + } - tree - } - else { - //Checking.typeChecker.traverse(tree.rhs) - cpy.TypeDef(tree)(rhs = TypeTree(tree.symbol.info)) - } - super.transform(tree1) + tree + } + super.transform(tree) case tree: MemberDef => transformMemberDef(tree) super.transform(tree) |