Skip to content

Commit 3d0accd

Browse files
committed
Fix transformation of inline body annotations
Previously we replaced them by ConcreteAnnotation so they became regular annotations and could be emitted in some cases. They need to keep being BodyAnnotation.
1 parent a4fea26 commit 3d0accd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package dotc
33
package transform
44

55
import dotty.tools.dotc.ast.tpd
6-
import dotty.tools.dotc.core.Annotations.ConcreteAnnotation
76
import dotty.tools.dotc.core.Contexts.Context
87
import dotty.tools.dotc.core.DenotTransformers.{InfoTransformer, DenotTransformer}
98
import dotty.tools.dotc.core.Denotations.SingleDenotation
@@ -181,10 +180,15 @@ object TreeTransforms {
181180
abstract override def transform(ref: SingleDenotation)(implicit ctx: Context): SingleDenotation =
182181
super.transform(ref) match {
183182
case ref1: SymDenotation if ref1.symbol.isDefinedInCurrentRun =>
184-
val annotTrees = ref1.annotations.map(_.tree)
183+
val annots = ref1.annotations
184+
val annotTrees = annots.map(_.tree)
185185
val annotTrees1 = annotTrees.mapConserve(annotationTransformer.macroTransform)
186186
if (annotTrees eq annotTrees1) ref1
187-
else ref1.copySymDenotation(annotations = annotTrees1.map(new ConcreteAnnotation(_)))
187+
else {
188+
val derivedAnnots = (annots, annotTrees1).zipped.map((annot, annotTree1) =>
189+
annot.derivedAnnotation(annotTree1))
190+
ref1.copySymDenotation(annotations = derivedAnnots)
191+
}
188192
case ref1 =>
189193
ref1
190194
}

0 commit comments

Comments
 (0)