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 - #2 by Natalia.Ukhorskaya
- Using External Annotations | The JetBrains Blog
- How to use external annotation on command line? - #3 by saltnlight5
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.: @org.jetbrains.annotations.NotNull
)?
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?