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#8250: Allow Expr.betaReduce to rewrite type ascriptions
When a blackbox inline def is inlined, a type ascription is added to preserve the apparent return type
of the inline def. Prior to this commit, the quoted.Expr.betaReduce function was unable to properly
inline a known lambda expression coming from an inline def as it would see the type ascription and
give up.
This change makes betaReduce rewrite type ascriptions, allowing it to inline type-ascribed functions such as those coming
from inlined defs.
- When type ascriptions are not present, behaviour does not change.
- When type ascriptions are encountered, the outermost ascription is kept.
- If the inline is successful, then the result type of the ascribed function type is ascribed to the inlined body.
- If the inline is not successful, the outermost ascribed type is re-ascribed to the non-inlineable expression before
inserting a call to that expression.
There are several test cases, covering:
- verifying that betaReduce can correctly reduce the application of the result of an inline def
to a constant value, with the reduction result being printed using the `compiletime.code` interpolator.
- verifying that the result type ascription handles dependent function types
- inserting ??? as either the inlined body or a function expression that cannot be inlined compiles without error (by
re-ascribing the apparent type)
- a neg-test that a function whose type is `Int=>Int` and whose body inlines to `4` does not typecheck against the
singleton type `4`.
0 commit comments