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:
Alexander Udalov
2023-04-25 00:59:52 +02:00
committed by Space Team
parent ea264cb5b5
commit fc0ce415d7
28 changed files with 746 additions and 90 deletions
@@ -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;
}
@@ -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;
}
@@ -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; }
}
@@ -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; }
}
@@ -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,3 +1,4 @@
// !LANGUAGE: -NoSourceCodeInNotNullAssertionExceptions
// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR
// Reason: KT-56760
// TARGET_BACKEND: JVM
@@ -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,3 +1,4 @@
// !LANGUAGE: -NoSourceCodeInNotNullAssertionExceptions
// IGNORE_BACKEND_K2_LIGHT_TREE: JVM_IR
// Reason: KT-56760
// TARGET_BACKEND: JVM
@@ -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; }
}
@@ -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; }
}