-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Handle binding of beta reduced inlined lambdas #16377
Conversation
f693e22
to
63c34cd
Compare
Handle all inline beta-reduction in the InlineReducer. All these applications will contain `Inlined` nodes that need to be handled without changing the nestedness of expressions in inlining scopes. Fixes scala#16374
63c34cd
to
4fded25
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 Inlined(call, bindings, expr) if bindings.forall(isPureBinding) => | ||
recur(expr).map(cpy.Inlined(cl)(call, bindings, _)) | ||
case Typed(expr, tpt) => | ||
recur(expr) |
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.
Any reason we don't preserve the Typed node here?
recur(expr) | |
recur(expr).map(cpy.Typed(cl)(_, tpt)) |
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.
It is intentional. This ascription is on the lambda and hence has the lambda type, but the result of this transformation has the type of the result of this lambda. Dropping it is the simplest option. We could attempt to add the ascription again on the result. This would be more complicated and would also prevent optimizations on constants. We also do the same in https://github.com/lampepfl/dotty/blob/main/compiler/src/dotty/tools/dotc/transform/BetaReduce.scala#L57-L58.
Handle all inline beta-reduction in the InlineReducer. All these
applications will contain
Inlined
nodes that need to be handledwithout changing the nestedness of expressions in inlining scopes.
Fixes #16374