In Java, I have the following method:
public Optional<Foo> getFoo() {
// always return some non-null value
}
In Kotlin code, the return type of this method is given as Optional<Foo!>!. By using the @Nonnull annotation I can cut this down to Optional<Foo!> (i.e. only the Foo type is not null-checked anymore).
Is there a way to annotate the method to make the Kotlin compiler null-check the return value correctly?