mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 15:53:19 +00:00
34 lines
645 B
Kotlin
Vendored
34 lines
645 B
Kotlin
Vendored
// TARGET_BACKEND: JVM
|
|
// STRICT_JAVA_NULLABILITY_ASSERTIONS
|
|
|
|
// See KT-8135
|
|
// We could generate runtime assertion on call site for 'generic<NOT_NULL_TYPE>()' below.
|
|
|
|
// FILE: box.kt
|
|
fun box(): String {
|
|
try {
|
|
J().test()
|
|
return "OK"
|
|
}
|
|
catch (e: Throwable) {
|
|
return "Fail: SHOULD NOT throw"
|
|
}
|
|
}
|
|
|
|
// FILE: test.kt
|
|
fun withAssertion(j: J) = generic<String?>(j)
|
|
|
|
fun <T> generic(j: J) = j.nullT<T>()
|
|
|
|
// FILE: J.java
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class J {
|
|
public <T> @NotNull T nullT() {
|
|
return null;
|
|
}
|
|
|
|
public void test() {
|
|
TestKt.withAssertion(this);
|
|
}
|
|
} |