@@ -168,19 +168,23 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
168
168
ttm(tree)
169
169
170
170
/** Transforms the given annotation tree. */
171
- private def transformAnnot (annot : Tree )(using Context ): Tree = {
171
+ private def transformAnnotTree (annot : Tree )(using Context ): Tree = {
172
172
val saved = inJavaAnnot
173
173
inJavaAnnot = annot.symbol.is(JavaDefined )
174
174
if (inJavaAnnot) checkValidJavaAnnotation(annot)
175
- try transform(copySymbols( annot) )
175
+ try transform(annot)
176
176
finally inJavaAnnot = saved
177
177
}
178
178
179
179
private def transformAnnot (annot : Annotation )(using Context ): Annotation =
180
- annot.derivedAnnotation(transformAnnot(annot.tree))
180
+ val tree1 =
181
+ annot match
182
+ case _ : BodyAnnotation => annot.tree
183
+ case _ => copySymbols(annot.tree)
184
+ annot.derivedAnnotation(transformAnnotTree(tree1))
181
185
182
186
/** Transforms all annotations in the given type. */
183
- private def transformAnnots (using Context ) =
187
+ private def transformAnnotsIn (using Context ) =
184
188
new TypeMap :
185
189
def apply (tp : Type ) = tp match
186
190
case tp @ AnnotatedType (parent, annot) =>
@@ -523,7 +527,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
523
527
Checking .checkRealizable(tree.tpt.tpe, tree.srcPos, " SAM type" )
524
528
super .transform(tree)
525
529
case tree @ Annotated (annotated, annot) =>
526
- cpy.Annotated (tree)(transform(annotated), transformAnnot (annot))
530
+ cpy.Annotated (tree)(transform(annotated), transformAnnotTree (annot))
527
531
case tree : AppliedTypeTree =>
528
532
if (tree.tpt.symbol == defn.andType)
529
533
Checking .checkNonCyclicInherited(tree.tpe, tree.args.tpes, EmptyScope , tree.srcPos)
@@ -546,7 +550,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
546
550
super .transform(tree)
547
551
case tree : TypeTree =>
548
552
val tpe = if tree.isInferred then CleanupRetains ()(tree.tpe) else tree.tpe
549
- tree.withType(transformAnnots (tpe))
553
+ tree.withType(transformAnnotsIn (tpe))
550
554
case Typed (Ident (nme.WILDCARD ), _) =>
551
555
withMode(Mode .Pattern )(super .transform(tree))
552
556
// The added mode signals that bounds in a pattern need not
0 commit comments