-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
f46077a
to
ecb8217
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- check PCP for annotations
- check annotations other than
ConcreteAnnotation
8a8595e
to
f4280ab
Compare
f4280ab
to
c13fac8
Compare
@liufengyun the two points where addressed |
@@ -62,7 +62,7 @@ class TreeMapWithImplicits extends tpd.TreeMap { | |||
private def nestedScopeCtx(defs: List[Tree])(implicit ctx: Context): Context = { | |||
val nestedCtx = ctx.fresh.setNewScope | |||
defs foreach { | |||
case d: DefTree => nestedCtx.enter(d.symbol) | |||
case d: DefTree if d.symbol.isOneOf(GivenOrImplicit) => nestedCtx.enter(d.symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change seems to break the originally intended semantics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is supposed to add the missing implicits into the scope. But adding other definitions interacts badly with on of the Yckeck while transforming an annotation containing a definition.
@@ -73,7 +73,7 @@ class TreeMapWithImplicits extends tpd.TreeMap { | |||
new TreeTraverser { | |||
def traverse(tree: Tree)(implicit ctx: Context): Unit = { | |||
tree match { | |||
case d: DefTree => nestedCtx.enter(d.symbol) | |||
case d: DefTree if d.symbol.isOneOf(GivenOrImplicit) => nestedCtx.enter(d.symbol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above.
@nicolasstucki The printing of the following program shows that the import scala.quoted._
class annot[T: Type](x: Expr[T]) extends scala.annotation.Annotation
class Test()(implicit qtx: QuoteContext) {
@annot('{4})
def foo(str: String) = '{4}
} I'm not sure if it's a bug or not, as annotations don't have runtime semantics. |
We should probably disallow quotes inside annotations. |
@nicolasstucki Do you prefer to handle the case in this PR, or in a later PR? |
Maybe let's open a separate issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
The issue is created: #7123 |
No description provided.