JVM: remove source code from not null assertion message text
This is implemented under a LanguageFeature which will be enabled later, when behavior change described in KT-57570 is approved. #KT-57570
This commit is contained in:
committed by
Space Team
parent
ea264cb5b5
commit
fc0ce415d7
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +NoSourceCodeInNotNullAssertionExceptions
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
f(J().s)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == "s must not be null")
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public String s = null;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: -NoSourceCodeInNotNullAssertionExceptions
|
||||
// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR
|
||||
// Reason: KT-56760
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
f(J().s)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == "J().s must not be null")
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public String s = null;
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: +NoSourceCodeInNotNullAssertionExceptions
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
val variable = J().s()
|
||||
f(variable)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == null)
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public final String s() { return null; }
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// !LANGUAGE: -NoSourceCodeInNotNullAssertionExceptions
|
||||
// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR
|
||||
// Reason: KT-56760
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
val variable = J().s()
|
||||
f(variable)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == "variable must not be null")
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public final String s() { return null; }
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +NoSourceCodeInNotNullAssertionExceptions
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
f(J().s())
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == "s(...) must not be null")
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public final String s() { return null; }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -NoSourceCodeInNotNullAssertionExceptions
|
||||
// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR
|
||||
// Reason: KT-56760
|
||||
// TARGET_BACKEND: JVM
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +NoSourceCodeInNotNullAssertionExceptions
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
f(J.s())
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == "s(...) must not be null")
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static String s() { return null; }
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// !LANGUAGE: -NoSourceCodeInNotNullAssertionExceptions
|
||||
// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR
|
||||
// Reason: KT-56760
|
||||
// TARGET_BACKEND: JVM
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +NoSourceCodeInNotNullAssertionExceptions
|
||||
// TARGET_BACKEND: JVM
|
||||
// IGNORE_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
f(J().s)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == "getS(...) must not be null")
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public String getS() { return null; }
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !LANGUAGE: -NoSourceCodeInNotNullAssertionExceptions
|
||||
// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR
|
||||
// Reason: KT-56760
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
return try {
|
||||
f(J().s)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message == "J().s must not be null")
|
||||
"OK"
|
||||
else
|
||||
"Fail: ${e.message}"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public String getS() { return null; }
|
||||
}
|
||||
Reference in New Issue
Block a user