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
Implements the scheme described in my comment to #7546.
- We type check an argument without or with flow info,
depending on whether the function part of the application
is known to take a call-by-name parameter. If we know nothing
about the function part, we assume call-by-value.
- At the end of type checking an application, if the argument is
known to be by-name, remove all x.$asInstanceOf$[T] casts in the
argument where x is a mutable variable, and run the type assigner
(not the type checker!) again on the result. If this succeeds and
gives a type that is still compatible with the formal parameter type,
we are done.
- Otherwise, issue an error saying that the argument cannot be treated
as call-by-name since it contains flow-assumptions about mutable variables.
As a remedy, suggest to wrap the argument in a `scala.compiletime.byName(...)`
call. Here, `byName` is defined as follws:
```
inline def byName[T](x: => T): T
```
Wrapping an argument with byName means that we know statically that
it is passed to a by-name parameter, so it will be typechecked without
flow info.
0 commit comments