diff options
author | Martin Odersky <odersky@gmail.com> | 2016-04-29 09:51:01 +0200 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-04-29 09:57:30 +0200 |
commit | e64c5610ac90d2e360bc3b1e7a5409e0a3547e67 (patch) | |
tree | 423ccca22176d739ad291d71ec0114c932b87ab5 /src/dotty/tools | |
parent | 96fcdd9da51e1febe9e320f774424b5ac3f8ff3d (diff) | |
download | dotty-e64c5610ac90d2e360bc3b1e7a5409e0a3547e67.tar.gz dotty-e64c5610ac90d2e360bc3b1e7a5409e0a3547e67.tar.bz2 dotty-e64c5610ac90d2e360bc3b1e7a5409e0a3547e67.zip |
Transform annotations only if defined in current run
There's no point transforming annotations that come from
classfiles. It's inefficient to do so and it's also risky
because it means we'd have to make sense of Scala-2 generated trees.
This should avoid the error in #1222.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeTransform.scala | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/transform/TreeTransform.scala b/src/dotty/tools/dotc/transform/TreeTransform.scala index 67bd2f160..abada9ab4 100644 --- a/src/dotty/tools/dotc/transform/TreeTransform.scala +++ b/src/dotty/tools/dotc/transform/TreeTransform.scala @@ -185,12 +185,19 @@ object TreeTransforms { ref match { case ref: SymDenotation => - val annotTrees = ref.annotations.map(_.tree) - val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform) - val annots1 = if (annotTrees eq annotTrees1) ref.annotations else annotTrees1.map(new ConcreteAnnotation(_)) + val annots1 = + if (!ref.symbol.isDefinedInCurrentRun) ref.annotations // leave annotations read from class files alone + else { + val annotTrees = ref.annotations.map(_.tree) + val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform) + if (annotTrees eq annotTrees1) ref.annotations + else annotTrees1.map(new ConcreteAnnotation(_)) + } if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref else ref.copySymDenotation(info = info1, annotations = annots1) - case _ => if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1) + case _ => + if (info1 eq ref.info) ref + else ref.derivedSingleDenotation(ref.symbol, info1) } } } |