You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The splice owner of the macro annotation should be the owner of the
annotated definition. The issue was that if that owner was a class
quotes unpickled with this context accidentally entered definitions
in the quotes into the class. Now we unpickle these definitions using
a dummy val owner (similar to the LocalDummy).
quotePickling.println(s"**** unpickling quote from TASTY\n${TastyPrinter.showContents(bytes, ctx.settings.color.value =="never")}")
252
+
valunpicklingContext=
253
+
if ctx.owner.isClass then
254
+
// When a quote is unpickled with a Quotes context that that has a class `spliceOwner`
255
+
// we need to use a dummy owner to unpickle it. Otherwise any definitions defined
256
+
// in the quoted block would be accidentally entered in the class.
257
+
// When splicing this expression, this owner is replaced with the correct owner (see `quotedExprToTree` and `quotedTypeToTree` above).
258
+
// On the other hand, if the expression is used as a reflect term, the user must call `changeOwner` (same as with other expressions used within a nested owner).
259
+
// `-Xcheck-macros` will check for inconsistent owners and provide the users hints on how to improve them.
260
+
//
261
+
// Quotes context that that has a class `spliceOwner` can come from a macro annotation
262
+
// or a user setting it explicitly using `Symbol.asQuotes`.
0 commit comments