@@ -168,19 +168,23 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
168168        ttm(tree)
169169
170170    /**  Transforms the given annotation tree. */  
171-     private  def  transformAnnot (annot : Tree )(using  Context ):  Tree  =  {
171+     private  def  transformAnnotTree (annot : Tree )(using  Context ):  Tree  =  {
172172      val  saved  =  inJavaAnnot
173173      inJavaAnnot =  annot.symbol.is(JavaDefined )
174174      if  (inJavaAnnot) checkValidJavaAnnotation(annot)
175-       try  transform(copySymbols( annot) )
175+       try  transform(annot)
176176      finally  inJavaAnnot =  saved
177177    }
178178
179179    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))
181185
182186    /**  Transforms all annotations in the given type. */  
183-     private  def  transformAnnots (using  Context ) = 
187+     private  def  transformAnnotsIn (using  Context ) = 
184188      new  TypeMap : 
185189        def  apply (tp : Type ) =  tp match 
186190          case  tp @  AnnotatedType (parent, annot) => 
@@ -523,7 +527,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
523527          Checking .checkRealizable(tree.tpt.tpe, tree.srcPos, " SAM type" 
524528          super .transform(tree)
525529        case  tree @  Annotated (annotated, annot) => 
526-           cpy.Annotated (tree)(transform(annotated), transformAnnot (annot))
530+           cpy.Annotated (tree)(transform(annotated), transformAnnotTree (annot))
527531        case  tree : AppliedTypeTree  => 
528532          if  (tree.tpt.symbol ==  defn.andType)
529533            Checking .checkNonCyclicInherited(tree.tpe, tree.args.tpes, EmptyScope , tree.srcPos)
@@ -546,7 +550,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
546550          super .transform(tree)
547551        case  tree : TypeTree  => 
548552          val  tpe  =  if  tree.isInferred then  CleanupRetains ()(tree.tpe) else  tree.tpe
549-           tree.withType(transformAnnots (tpe))
553+           tree.withType(transformAnnotsIn (tpe))
550554        case  Typed (Ident (nme.WILDCARD ), _) => 
551555          withMode(Mode .Pattern )(super .transform(tree))
552556            //  The added mode signals that bounds in a pattern need not
0 commit comments