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
Check restrictions on how this values can be used in constructors.
Essentially, `this` cannot be used before the super constructor
call, except to assign fields (but not reading).
These restrictions match those enforced by the JVM for bytecode.
While we never intended `this` values to be restricted in this way,
in practice we never produced IR that would violate those
restrictions.
There was one exception before the parent commit: we could have
lifted methods coming from the arguments to a super constructor
call. Since they were lifted as instance methods, they caused the
constructor to refer to `this` before the super constructor call.
This is in theory a backward breaking change in the IR! However,
we audited the entire ecosystem of libraries published on Maven
Central. None of them contained IR that violates the new
restriction.
In the future, we may leverage those restrictions to validate
strict field initialization. If a field *needs* to be initialized
before it is ever read (for example, because it has a non-nullable
reference type), then we can do so: we only have to check that it
is definitely initialized before the super constructor call. The
restrictions implemented in this commit ensure that nobody can
read the field before the super constructor call starts.
0 commit comments