@@ -146,19 +146,23 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
146
146
ttm(tree)
147
147
148
148
/** Transforms the given annotation tree. */
149
- private def transformAnnot (annot : Tree )(using Context ): Tree = {
149
+ private def transformAnnotTree (annot : Tree )(using Context ): Tree = {
150
150
val saved = inJavaAnnot
151
151
inJavaAnnot = annot.symbol.is(JavaDefined )
152
152
if (inJavaAnnot) checkValidJavaAnnotation(annot)
153
- try transform(copySymbols( annot) )
153
+ try transform(annot)
154
154
finally inJavaAnnot = saved
155
155
}
156
156
157
157
private def transformAnnot (annot : Annotation )(using Context ): Annotation =
158
- annot.derivedAnnotation(transformAnnot(annot.tree))
158
+ val tree1 =
159
+ annot match
160
+ case _ : BodyAnnotation => annot.tree
161
+ case _ => copySymbols(annot.tree)
162
+ annot.derivedAnnotation(transformAnnotTree(tree1))
159
163
160
164
/** Transforms all annotations in the given type. */
161
- private def transformAnnots (using Context ) =
165
+ private def transformAnnotsIn (using Context ) =
162
166
new TypeMap :
163
167
def apply (tp : Type ) = tp match
164
168
case tp @ AnnotatedType (parent, annot) =>
@@ -460,7 +464,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
460
464
Checking .checkRealizable(tree.tpt.tpe, tree.srcPos, " SAM type" )
461
465
super .transform(tree)
462
466
case tree @ Annotated (annotated, annot) =>
463
- cpy.Annotated (tree)(transform(annotated), transformAnnot (annot))
467
+ cpy.Annotated (tree)(transform(annotated), transformAnnotTree (annot))
464
468
case tree : AppliedTypeTree =>
465
469
if (tree.tpt.symbol == defn.andType)
466
470
Checking .checkNonCyclicInherited(tree.tpe, tree.args.tpes, EmptyScope , tree.srcPos)
@@ -482,7 +486,7 @@ class PostTyper extends MacroTransform with IdentityDenotTransformer { thisPhase
482
486
report.error(em " type ${alias.tpe} outside bounds $bounds" , tree.srcPos)
483
487
super .transform(tree)
484
488
case tree : TypeTree =>
485
- tree.withType(transformAnnotsIn(tpe))
489
+ tree.withType(transformAnnotsIn(tree. tpe))
486
490
case Typed (Ident (nme.WILDCARD ), _) =>
487
491
withMode(Mode .Pattern )(super .transform(tree))
488
492
// The added mode signals that bounds in a pattern need not
0 commit comments