Skip to content

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

Merged
merged 3 commits into from
Aug 10, 2020

Conversation

nicolasstucki
Copy link
Contributor

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.

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`.
@nicolasstucki nicolasstucki marked this pull request as ready for review August 8, 2020 19:03
Copy link
Contributor

@liufengyun liufengyun left a 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

Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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>
@nicolasstucki nicolasstucki merged commit ea51ad7 into scala:master Aug 10, 2020
@nicolasstucki nicolasstucki deleted the add-asExprOf branch August 10, 2020 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants