Skip to content

Commit f46077a

Browse files
committed
Fix #7052: Transform annotations in ReifyQuotes
1 parent 0ebbcff commit f46077a

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import dotty.tools.dotc.ast.tpd
1919
import typer.Implicits.SearchFailureType
2020

2121
import scala.collection.mutable
22-
import dotty.tools.dotc.core.Annotations.Annotation
22+
import dotty.tools.dotc.core.Annotations._
2323
import dotty.tools.dotc.core.Names._
2424
import dotty.tools.dotc.core.StdNames._
2525
import dotty.tools.dotc.core.quoted._
@@ -405,6 +405,15 @@ class ReifyQuotes extends MacroTransform {
405405
// TODO move to FirstTransform to trigger even without quotes
406406
cpy.DefDef(tree)(rhs = defaultValue(tree.rhs.tpe))
407407

408+
case tree: DefTree if level >= 1 =>
409+
val newAnnotations = tree.symbol.annotations.mapconserve {
410+
case ConcreteAnnotation(annotTree) =>
411+
val newAnnotTree = transform(annotTree) given ctx.withOwner(tree.symbol)
412+
ConcreteAnnotation(newAnnotTree)
413+
case annot => annot
414+
}
415+
tree.symbol.annotations = newAnnotations
416+
super.transform(tree)
408417
case _ =>
409418
super.transform(tree)
410419
}

tests/pos/i7052.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import scala.quoted._
2+
class Test {
3+
def foo(str: Expr[String]) given QuoteContext = '{
4+
@deprecated($str, "")
5+
def bar = ???
6+
}
7+
}

0 commit comments

Comments
 (0)