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
`ClassType`s and `ArrayType`s now carry a `nullable: Boolean` flag.
When `nullable` is false, the type does not admit `null` values.
We also introduce `AnyNotNullType` to be the non-nullable variant
of `AnyType`.
This way, every non-void type `tpe` has a non-nullable variant,
which we can get with `tpe.toNonNullable`.
There are a few sources of non-nullable values, such as `New`
nodes, and, most importantly, `This` nodes.
Since non-nullable reference types have no corresponding `TypeRef`,
they cannot appear in the signature of methods. They only live
locally within method bodies.
---
The optimizer already had dedicated tracking of non-nullable
`PreTransform`s. We now replace that tracking by the actual `tpe`
of the trees.
In order to be type-preserving, we must now insert most `Cast`s,
to non-nullable types. Before, at the IR level everything became
nullable again, so even if the optimizer had determined that a tree
could not be null, that did not influence the produced IR.
On the plus side, since IR nodes track their nullability, we do not
need `AssumeNotNull` anymore. The `Cast`s to non-nullable types
achieve the same result in a more consistent way.
In fact, the new non-nullable types allow the optimizer to better
keep track of nullability, resulting in fewer `$n` calls to check
for nulls. This is the main source of code side reduction.
---
Since we now have non-nullable reference types, we change
`IsInstanceOf` to require non-nullable test types. This makes more
sense, since `IsInstanceOf` always answers `false` when the value
is `null`.
---
We introduce deserialization hacks to:
* adapt the type of `This` nodes, and
* adapt the test type of `IsInstanceOf` nodes.
In this commit, we do not change the compiler nor the hard-coded IR
of `jl.Object` yet, in order to test the deserialization hacks.
0 commit comments