-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Use asRefelctTree #10287
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
Use asRefelctTree #10287
Conversation
36bc658
to
1c73259
Compare
@@ -23,7 +23,7 @@ object Const { | |||
case Inlined(_, Nil, e) => rec(e) | |||
case _ => None | |||
} | |||
rec(expr.unseal) | |||
rec(expr.asReflectTree) |
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.
Do we have trees other than reflect trees? What about call it 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.
We have other things in reflect
such as TypeRepr
, Position
, Symbol
, ... . All things that could be taken out from this expression.
There is also a better use of reflect
in #10289.
We also want the method to be a bit longer to make it pop out a bit bore in the source as this is where we go into the other API.
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.
Looking at the changes, for meta-programmers, asReflectTree
seems a little verbose. What about expr.asTree
?
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.
Perfect, that was the intention. We want to stop anyone that does not need to use it for calling it in the middle of some code just because it has a short name.
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.
asTree
tempted as a first option but I noticed that it was too dangerous and the changed to asReflectTree
to have something that is immediately associated with reflect.Tree
.
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.
The only realistic alternative we have is to remove this method and create one in the module of Tree
or Term
.
- val tree: Term = expr.asReflectTree
+ val tree: Term = Term.of(expr)
+ val tree: Term = Tree.of(expr)
This keeps the short name and has the added advantage that we need to import qctx.reflect._
or use the path explicitly (making it clear where we change from one API to the other).
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.
I opened #10332 with this alternative. This alternative looks better and is more inline with the rest of the API
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.
That sounds like a better alternative 👍
1c73259
to
8844bfe
Compare
8844bfe
to
b25eb23
Compare
No description provided.