[IR] Restore and fix ifConstVal test
It was accidentally dropped after KT-55196 fix.
This commit is contained in:
+4
-1
@@ -194,7 +194,10 @@ private fun FirExpression.isForbiddenComplexConstant(session: FirSession): Boole
|
||||
val forbidComplexBooleanExpressions = session.languageVersionSettings.supportsFeature(
|
||||
LanguageFeature.ProhibitSimplificationOfNonTrivialConstBooleanExpressions
|
||||
)
|
||||
return isComplexBooleanConstant && forbidComplexBooleanExpressions
|
||||
val intrinsicConstEvaluation = session.languageVersionSettings.supportsFeature(
|
||||
LanguageFeature.IntrinsicConstEvaluation
|
||||
)
|
||||
return !intrinsicConstEvaluation && forbidComplexBooleanExpressions && isComplexBooleanConstant
|
||||
}
|
||||
|
||||
private val FirExpression.isComplexBooleanConstant
|
||||
|
||||
+6
@@ -29170,6 +29170,12 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -29170,6 +29170,12 @@ public class FirLightTreeBlackBoxCodegenWithIrFakeOverrideGeneratorTestGenerated
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -29170,6 +29170,12 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !LANGUAGE: +IntrinsicConstEvaluation
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
// TARGET_BACKEND: JS_IR
|
||||
// TARGET_BACKEND: NATIVE
|
||||
// IGNORE_BACKEND_K1: JVM_IR, JS_IR, JS_IR_ES6, NATIVE
|
||||
fun <T> T.id() = this
|
||||
|
||||
const val flag = <!EVALUATED("true")!>true<!>
|
||||
const val value = <!EVALUATED("10")!>10<!>
|
||||
const val condition = <!EVALUATED("True")!>if (flag) "True" else "Error"<!>
|
||||
const val withWhen = <!EVALUATED("True")!>when (flag) { true -> "True"; else -> "Error" }<!>
|
||||
const val withWhen2 = <!EVALUATED("True")!>when { flag == true -> "True"; else -> "Error" }<!>
|
||||
const val withWhen3 = <!EVALUATED("1")!>when(value) { 10 -> "1"; 100 -> "2"; else -> "3" }<!>
|
||||
const val multibranchIf = <!EVALUATED("3")!>if (value == 100) 1 else if (value == 1000) 2 else 3<!>
|
||||
|
||||
// STOP_EVALUATION_CHECKS
|
||||
fun box(): String {
|
||||
if (condition.id() != "True") return "Fail 1"
|
||||
if (withWhen.id() != "True") return "Fail 2"
|
||||
if (withWhen2.id() != "True") return "Fail 3"
|
||||
if (withWhen3.id() != "1") return "Fail 4"
|
||||
if (multibranchIf.id() != 3) return "Fail 5"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// !LANGUAGE: +IntrinsicConstEvaluation
|
||||
|
||||
const val equalsBoolean1 = true.equals(true)
|
||||
const val equalsBoolean2 = false != true
|
||||
const val equalsBoolean3 = false.equals(1)
|
||||
const val equalsBoolean4 = <!EQUALITY_NOT_APPLICABLE!>false == 1<!>
|
||||
|
||||
const val equalsChar1 = '1'.equals('2')
|
||||
const val equalsChar2 = '2' == '2'
|
||||
const val equalsChar3 = '1'.equals(1)
|
||||
const val equalsChar4 = <!EQUALITY_NOT_APPLICABLE!>'1' == 1<!>
|
||||
|
||||
const val equalsByte1 = 1.toByte().equals(2.toByte())
|
||||
const val equalsByte2 = 2.toByte() == 2.toByte()
|
||||
const val equalsByte3 = 1.toByte().equals("1")
|
||||
const val equalsByte4 = <!EQUALITY_NOT_APPLICABLE!>1.toByte() == "1"<!>
|
||||
|
||||
const val equalsShort1 = 1.toShort().equals(2.toShort())
|
||||
const val equalsShort2 = 2.toShort() == 2.toShort()
|
||||
const val equalsShort3 = 1.toShort().equals("1")
|
||||
const val equalsShort4 = <!EQUALITY_NOT_APPLICABLE!>1.toShort() == "1"<!>
|
||||
|
||||
const val equalsInt1 = 1.equals(2)
|
||||
const val equalsInt2 = 2 == 2
|
||||
const val equalsInt3 = 1.equals("1")
|
||||
const val equalsInt4 = <!EQUALITY_NOT_APPLICABLE!>1 == "1"<!>
|
||||
|
||||
const val equalsLong1 = 1L.equals(2L)
|
||||
const val equalsLong2 = 2L == 2L
|
||||
const val equalsLong3 = 1L.equals("1")
|
||||
const val equalsLong4 = <!EQUALITY_NOT_APPLICABLE!>1L == "1"<!>
|
||||
|
||||
const val equalsFloat1 = 1.0f.equals(2.0f)
|
||||
const val equalsFloat2 = 2.0f == 2.0f
|
||||
const val equalsFloat3 = 1.0f.equals("1")
|
||||
const val equalsFloat4 = <!EQUALITY_NOT_APPLICABLE!>1.0f == "1"<!>
|
||||
|
||||
const val equalsDoable1 = 1.0.equals(2.0)
|
||||
const val equalsDoable2 = 2.0 == 2.0
|
||||
const val equalsDoable3 = 1.0.equals("1")
|
||||
const val equalsDoable4 = <!EQUALITY_NOT_APPLICABLE!>1.0 == "1"<!>
|
||||
|
||||
const val equalsString1 = "someStr".equals("123")
|
||||
const val equalsString2 = "someStr" == "otherStr"
|
||||
const val equalsString3 = "someStr".equals(1)
|
||||
const val equalsString4 = <!EQUALITY_NOT_APPLICABLE!>"someStr" == 1<!>
|
||||
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +IntrinsicConstEvaluation
|
||||
|
||||
const val equalsBoolean1 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>true.equals(true)<!>
|
||||
|
||||
+4
-4
@@ -4,19 +4,19 @@ const val flag = true
|
||||
const val value = 10
|
||||
|
||||
const val condition = if (flag) "True" else "Error"
|
||||
const val withWhen = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>when (flag) {
|
||||
const val withWhen = when (flag) {
|
||||
true -> "True"
|
||||
else -> "Error"
|
||||
}<!>
|
||||
}
|
||||
const val withWhen2 = when {
|
||||
flag == true -> "True"
|
||||
else -> "Error"
|
||||
}
|
||||
const val withWhen3 = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>when(value) {
|
||||
const val withWhen3 = when(value) {
|
||||
10 -> "1"
|
||||
100 -> "2"
|
||||
else -> "3"
|
||||
}<!>
|
||||
}
|
||||
const val multibranchIf = if (value == 100) 1 else if (value == 1000) 2 else 3
|
||||
|
||||
val nonConstFlag = true
|
||||
|
||||
+6
@@ -29170,6 +29170,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -29170,6 +29170,12 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+5
@@ -24614,6 +24614,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/enumName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void ignoreIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void ignoreKCallableName() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/kCallableName.kt");
|
||||
|
||||
+6
@@ -21652,6 +21652,12 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
Generated
+6
@@ -21652,6 +21652,12 @@ public class FirJsES6CodegenBoxTestGenerated extends AbstractFirJsES6CodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -21652,6 +21652,12 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -21652,6 +21652,12 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -24483,6 +24483,12 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -24963,6 +24963,12 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -24244,6 +24244,12 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
+6
@@ -24484,6 +24484,12 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/equals_after.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("ifConstVal.kt")
|
||||
public void testIfConstVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/involvesIrInterpreter/intrinsicConst/ifConstVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("kCallableName.kt")
|
||||
public void testKCallableName() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user