Use Intrinsics.checkNotNullParameter to throw NPE in parameter null checks
Similarly to previous commits, this method was unused, so we're changing its semantics in API version >= 1.4. #KT-22275 In Progress
This commit is contained in:
+25
@@ -0,0 +1,25 @@
|
||||
// !API_VERSION: LATEST
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public static void test() {
|
||||
new B().foo(null);
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class B {
|
||||
fun foo(s: String) {}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
A.test()
|
||||
return "Fail: NPE should have been thrown"
|
||||
} catch (e: Throwable) {
|
||||
if (e::class != NullPointerException::class) return "Fail: exception class should be NPE: ${e::class}"
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user