-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Replace scala.quoted.qctx
with scala.quoted.reflect
#10289
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
Replace scala.quoted.qctx
with scala.quoted.reflect
#10289
Conversation
Is the Scala 3 feature going to stay? The worry I have is that either Scala 3 drops the feature or it makes Scala 3 difficult to drop the feature. |
4cd4497
to
ddc1bb3
Compare
Which feature? |
ddc1bb3
to
b85f2fc
Compare
I mean the following: def reflect(using qctx: QuoteContext): qctx.reflect.type = qctx.reflect |
I don't understand how this works, |
That def reflect(using q: QuoteContext): q.reflect.type = q.reflect
def f(using q: QuoteContext)
// reflect.Tree ==> reflect(q).Tree ==> q.reflect.Tree
import reflect.Tree
|
We need to support that, it is equivalent to a more concrete version of inline def summon[T](using x: T): x.type = x If we would drop the feature we would have to remove |
96f3759
to
69890f9
Compare
69890f9
to
4286623
Compare
* def f(using QuoteContext)(tree: reflect.Tree): reflect.Position = ... | ||
* ``` | ||
*/ | ||
def reflect(using qctx: QuoteContext): qctx.reflect.type = qctx.reflect |
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.
What about #10295 ? There is no precedent in the language where we can import an unstable prefix. Or at least, with inline and checks?
Meanwhile, it seems to me that import qctx.reflect._
is better than import reflect._
, as the former tells some information about the relationship between qctx
and reflect
, while the latter makes me wonder what's the magic behind.
The only reason we added
qctx
was to have a simple way to access the reflection in context usingqctx.reflect
. There are no other uses of this method. It is much simpler for users if they a provided with the methodreflect
that those the same asqctx.reflect
. The nameqctx
is also a bit obscure and is not that simple to identify in the API.To use reflection inside a method
or to use reflection in the signature of a method