Skip to content

Commit 2da00f7

Browse files
committed
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.
1 parent 96fcdd9 commit 2da00f7

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/dotty/tools/dotc/transform/TreeTransform.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,15 @@ object TreeTransforms {
184184
val info1 = transformInfo(ref.info, ref.symbol)
185185

186186
ref match {
187-
case ref: SymDenotation =>
187+
case ref: SymDenotation if ref.symbol.isDefinedInCurrentRun =>
188+
// leave annotations read from class files alone
188189
val annotTrees = ref.annotations.map(_.tree)
189190
val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform)
190191
val annots1 = if (annotTrees eq annotTrees1) ref.annotations else annotTrees1.map(new ConcreteAnnotation(_))
191192
if ((info1 eq ref.info) && (annots1 eq ref.annotations)) ref
192193
else ref.copySymDenotation(info = info1, annotations = annots1)
193-
case _ => if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1)
194+
case _ =>
195+
if (info1 eq ref.info) ref else ref.derivedSingleDenotation(ref.symbol, info1)
194196
}
195197
}
196198
}

0 commit comments

Comments
 (0)