JVM: do not put public field access into a single expression block
It affects the `is IrGetField` check in TypeOperatorLowering.computeNotNullAssertionText, which leads to missing NPE messages when accessing backing fields of public properties. #KT-64615
This commit is contained in:
committed by
Space Team
parent
96b2f13397
commit
f01e633f8b
+29
@@ -0,0 +1,29 @@
|
||||
// !LANGUAGE: +NoSourceCodeInNotNullAssertionExceptions
|
||||
// TARGET_BACKEND: JVM
|
||||
// FILE: test.kt
|
||||
|
||||
val publicProperty = J().s()
|
||||
private val privateProperty = J().s()
|
||||
|
||||
fun f(x: String) = "Fail 1"
|
||||
|
||||
fun box(): String {
|
||||
try {
|
||||
f(publicProperty)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message != "publicProperty must not be null") return "Fail 2: ${e.message}"
|
||||
}
|
||||
|
||||
try {
|
||||
f(privateProperty)
|
||||
} catch (e: NullPointerException) {
|
||||
if (e.message != "privateProperty must not be null") return "Fail 3: ${e.message}"
|
||||
}
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public final String s() { return null; }
|
||||
}
|
||||
Reference in New Issue
Block a user