From e64c5610ac90d2e360bc3b1e7a5409e0a3547e67 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Fri, 29 Apr 2016 09:51:01 +0200 Subject: 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. --- src/dotty/tools/dotc/transform/TreeTransform.scala | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/dotty/tools/dotc/transform/TreeTransform.scala') 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) } } } -- cgit v1.2.3