-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add quoted.Expr.asExprOf and Reflection.Tree.{asExprOf, isExpr} #9514
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
These methods allow checked casts from `Expr` or a `Tree`. `Tree.asExprOf` is similar to `Trem.seal` with the difference that it also checks if the tree is a valid term. Add `isExpr` and improve implemetation of `seal`, `sealOpt` and `ExprMap`.
d545392
to
9b9ca24
Compare
0eb74e6
to
e3ddbab
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.
Otherwise, LGTM
case _: MethodType | _: PolyType => false | ||
case _ => true | ||
case _ => false | ||
|
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 isExpr
will cause confusion for meta-programmers: what's the relation between expression
and Expr[T]
? What is the relationship between expression
and Term
?
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 is isExpr
indicates that this term is a valid Expr[Any]
, therefore asExprOf
will succeed. The names are intentionally similar as the are about the same concept. Docs can improve.
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.
Maybe make the method private?
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.
But users are intended to use it
Co-authored-by: Fengyun Liu <liu@fengy.me>
These methods allow checked casts from
Expr
or aTree
.Tree.asExprOf
is similar toTrem.seal
with the difference that it also checks if the tree is a valid term.Add
isExpr
and improve implemetation ofseal
,sealOpt
andExprMap
.