-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Improve constant folding logic #12080
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
b28e5b2
to
ca46f64
Compare
* Better handling of inlined expression * Constant fold `String.!=` * Handle `null` in `==` and `!=` Fixes scala#12072
ca46f64
to
6a25712
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
@@ -59,6 +59,16 @@ object ConstFold: | |||
tree.withFoldedType(Constant(targ.tpe)) | |||
case _ => tree | |||
|
|||
private def treeConstant(tree: Tree)(using Context): Option[Constant] = |
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 think it would be more elegant if ConstantTree
was an extractor.
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.
Moved to ConstantTree
extractor
I'm not sure if it's relevant here, but is it possible to have constant folding in string interpolation (meaning that if all arguments are constant then the interpolation result will be constant as well)? |
Constant folding on string interpolators is a separate and more complex issue (see #10315). |
String.!=
null
in==
and!=
Fixes #12072