You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix#8306: Ensure the inliner can elide effectively pure case class applications in various situations
This is a collection of related changes, all to ensure that the inliner is capable of properly eliding case class
constructions in various situations.
Specific intended changes:
- allow NewInstance.unapply to look past type ascriptions
- change all purity checks to consider, for the inliner only, case class applications (when the apply method is synthetic
and the case class has no constructor body) pure, or "elideable", despite the fact that the operation is almost always
idempotent in the general case.
- make reduceInlineMatch's reduceSubPatterns procedure set the defTree for the accessor projections it generates, so nested
Unapply patterns can look in defTree to find and possible inline the appropriate subtree of the scrutinee expression
- make the typedSelect override able to reduce projections without a corresponding inline match, so that if inlining
produces SomeCaseClass(x=3).x the case class construction has a change to be elided (only in an inline context)
This commit also includes a series of test cases which use compiletime.show to pretty-print the resulting inlined AST of a
series of inline expansions. To avoid cases where a malformed AST pretty-prints but causes bad codegen, the computed
run-time value is also printed.
One last thing I tested manually was that the bytecode matched the pretty-printing. Mid-work on this commit I found that
the pretty printer was hiding several cases where redundant code was left in but not showing up when pretty-printed. This
is partially tested by the case where full inlining is not possible, which would also include a redundant binding for the
scrutinee if that issue were still present.
0 commit comments