It seems like there used to be a way to produce compile time nullability errors using external annotations, as described in the following pages:
- External Annotations
- How to use external annotation on command line?
This was a few years ago. Since then, it seems like the
-annotations compiler option was removed, same with Gradle
kotlinOptions.annotations option. What happened? Is this due to the introduction of platform types (types with
!)? Or because the compiler now recognizes direct annotations (e.g.:
I think it would still make sense to produce compile time errors for externally annotated types. For example, some of the Java API appears as externally annotated in IntelliJ, like the
File class. The constructor
File(@NotNull String pathname) (where
@NotNull is added externally) compiles without error when you do
File(null as String?). But it would throw a compile-time error if the type was directly annotated.
Why is there no option to do the same with external annotations? Or did I miss something?