-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
We now build the entire standard library with explicit nulls enabled. While it is obviously good to have added internal guarantees, it also means that the published artifact comes from this compilation mode. This can lead to 2 things:
- Types of the form
X | Null
can appear whereX
was used before. FlexibleType
s can appear.
They can appear a) in APIs and b) in the TASTy body of methods.
Number 1. is no big deal, whether in public APIs or method bodies. When interpreted without explicit nulls, X | Null =:= X
, so it does not make a difference.
FlexibleType
s are more problematic, as they are not, in fact, stable.
In APIs, this is of course a big issue. Fortunately, we can prevent that from happening by making sure to fully annotate the result types. That is considered good practice for public and protected methods; not always for val
s. Ideally we would implement some automated check to make sure that we don't leak any FlexibleType
s in the APIs.
In the method bodies, the issue is less problematic. The compiler only looks at method bodies for inline
methods. Here as well, ideally an automated check could make sure that no inline
methods contains any FlexibleType
.
Other tooling, besides the compiler, can definitely look at method bodies, though. For example, tasty-query
has effectively had to fully support FlexibleType
s since they were introduced, even though they are not stable, because they often appear in method bodies. It is unclear to me how we can defend against that.