Skip to content

Fix #7052: Transform annotations in ReifyQuotes #7053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion compiler/src/dotty/tools/dotc/transform/ReifyQuotes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import dotty.tools.dotc.ast.tpd
import typer.Implicits.SearchFailureType

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

case tree: DefTree if level >= 1 =>
val newAnnotations = tree.symbol.annotations.mapconserve {
case ConcreteAnnotation(annotTree) =>
val newAnnotTree = transform(annotTree) given ctx.withOwner(tree.symbol)
ConcreteAnnotation(newAnnotTree)
case annot => annot
}
tree.symbol.annotations = newAnnotations
super.transform(tree)
case _ =>
super.transform(tree)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotc/pos-from-tasty.blacklist
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ t3612.scala

# Other failure
t802.scala
i7052.scala
7 changes: 7 additions & 0 deletions tests/pos/i7052.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import scala.quoted._
class Test {
def foo(str: Expr[String]) given QuoteContext = '{
@deprecated($str, "")
def bar = ???
}
}