Files
kotlin-fork/compiler/testData/diagnostics/foreignAnnotationsTests/tests/kt50734.kt
T
Victor Petukhov 6c994787b3 [FE 1.0] Don't expand type enhancement
Actually shallow type enhancement is primary, it's more specific

^KT-50734 Fixed
2022-05-17 07:38:26 +00:00

41 lines
1.2 KiB
Kotlin
Vendored

// FILE: Supplier.java
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.annotations.Nullable;
// Shown from RxJava for reference
@FunctionalInterface
public interface Supplier<@NonNull T> {
T get() throws Throwable;
}
// FILE: Maybe.java
public abstract class Maybe<T> {
public final void subscribe() {}
}
// FILE: FromSupplier.java
import io.reactivex.rxjava3.annotations.NonNull;
import io.reactivex.rxjava3.annotations.Nullable;
public class FromSupplier {
static <@NonNull T> Maybe<T> fromSupplier3(Supplier<? extends @Nullable T> supplier) {
return null;
}
static <@NonNull T> Maybe<T> fromSupplier5(@NonNull Supplier<? extends @Nullable T> supplier) {
return null;
}
}
// FILE: main.kt
fun main() {
// No Warning
// In this case, we have nullable type enhancement
FromSupplier.fromSupplier3<Boolean> { <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!> }
.subscribe()
// In this case, we have not-null type enhancement
// Warning: Type Mismatch: Required Boolean? found Nothing
FromSupplier.fromSupplier5<Boolean> { <!NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS!>null<!> }
.subscribe()
}