[IR] Add new test to check that nullable access to enum is not evaluated

Just a safety check. If an expression like `EnumClass.Value?.name` was
evaluated, we would consider it as breaking change.
This commit is contained in:
Ivan Kylchik
2023-07-17 13:57:20 +02:00
committed by Space Team
parent d0da736b13
commit 88191e8b1a
13 changed files with 91 additions and 0 deletions
@@ -28873,6 +28873,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -28873,6 +28873,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM_IR
// TARGET_BACKEND: JS_IR
// TARGET_BACKEND: NATIVE
// WITH_STDLIB
fun <T> T.id() = this
enum class EnumClass {
OK
}
val shouldNotBeEvaluated1 = EnumClass.OK?.name ?: ""
val shouldNotBeEvaluated2 = EnumClass.OK?.name?.toString()
val shouldNotBeEvaluated3 = EnumClass.OK?.name.toString()
fun box(): String {
if (shouldNotBeEvaluated1 != "OK") return "Fail 1"
if (shouldNotBeEvaluated2 != "OK") return "Fail 2"
if (shouldNotBeEvaluated3 != "OK") return "Fail 3"
return shouldNotBeEvaluated1.id()
}
@@ -28873,6 +28873,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -28873,6 +28873,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -24375,6 +24375,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@TestMetadata("compiler/testData/codegen/box/involvesIrInterpreter/serialization")
@@ -21397,6 +21397,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -21397,6 +21397,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -21397,6 +21397,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -24222,6 +24222,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -24698,6 +24698,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -23985,6 +23985,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested
@@ -24223,6 +24223,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
public void testKt58717() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kt58717.kt");
}
@Test
@TestMetadata("nullableEnumName.kt")
public void testNullableEnumName() throws Exception {
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/nullableEnumName.kt");
}
}
@Nested