JVM: do not generate assertion message for captured fields
#KT-64615 Fixed
This commit is contained in:
committed by
Space Team
parent
f01e633f8b
commit
dd5fffebf2
+6
@@ -31442,6 +31442,12 @@ public class LLFirBlackBoxCodegenBasedTestGenerated extends AbstractLLFirBlackBo
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+6
@@ -31442,6 +31442,12 @@ public class LLFirReversedBlackBoxCodegenBasedTestGenerated extends AbstractLLFi
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+6
@@ -31051,6 +31051,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+6
@@ -31051,6 +31051,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+6
@@ -31051,6 +31051,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+4
-1
@@ -766,7 +766,10 @@ private class TypeOperatorLowering(private val backendContext: JvmBackendContext
|
|||||||
if (backendContext.config.noSourceCodeInNotNullAssertionExceptions) {
|
if (backendContext.config.noSourceCodeInNotNullAssertionExceptions) {
|
||||||
return when (val argument = typeOperatorCall.argument) {
|
return when (val argument = typeOperatorCall.argument) {
|
||||||
is IrCall -> "${argument.symbol.owner.name.asString()}(...)"
|
is IrCall -> "${argument.symbol.owner.name.asString()}(...)"
|
||||||
is IrGetField -> argument.symbol.owner.name.asString()
|
is IrGetField -> {
|
||||||
|
val field = argument.symbol.owner
|
||||||
|
field.name.asString().takeUnless { field.origin.isSynthetic }
|
||||||
|
}
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
// !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()
|
||||||
|
val block = { f(variable) }
|
||||||
|
block()
|
||||||
|
} catch (e: NullPointerException) {
|
||||||
|
if (e.message == null)
|
||||||
|
"OK"
|
||||||
|
else
|
||||||
|
"Fail: ${e.message}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: J.java
|
||||||
|
public class J {
|
||||||
|
public final String s() { return null; }
|
||||||
|
}
|
||||||
+6
@@ -31051,6 +31051,12 @@ public class JvmAbiConsistencyTestBoxGenerated extends AbstractJvmAbiConsistency
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+6
@@ -29329,6 +29329,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+6
@@ -31051,6 +31051,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+6
@@ -31051,6 +31051,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
|
|||||||
+5
@@ -26302,6 +26302,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/backingField.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("capturedVariable.kt")
|
||||||
|
public void testCapturedVariable() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/capturedVariable.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("field_after.kt")
|
@TestMetadata("field_after.kt")
|
||||||
public void testField_after() throws Exception {
|
public void testField_after() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/field_after.kt");
|
runTest("compiler/testData/codegen/box/javaInterop/notNullAssertions/expressionAssertionMessages/field_after.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user