[FIR2IR] Fix interpreting constants from const properties from other module
This commit is contained in:
committed by
TeamCityServer
parent
a7e6667648
commit
245bc7c8e2
+6
@@ -7026,6 +7026,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
|
||||
+5
-2
@@ -76,7 +76,10 @@ class IrCompileTimeChecker(
|
||||
override fun visitElement(element: IrElement, data: Nothing?) = false
|
||||
|
||||
private fun visitStatements(statements: List<IrStatement>, data: Nothing?): Boolean {
|
||||
if (mode == EvaluationMode.ONLY_BUILTINS) return false
|
||||
if (mode == EvaluationMode.ONLY_BUILTINS) {
|
||||
val statement = statements.singleOrNull() ?: return false
|
||||
return statement is IrConst<*>
|
||||
}
|
||||
return statements.all { it.accept(this, data) }
|
||||
}
|
||||
|
||||
@@ -263,4 +266,4 @@ class IrCompileTimeChecker(
|
||||
override fun visitThrow(expression: IrThrow, data: Nothing?): Boolean {
|
||||
return expression.value.accept(this, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
// MODULE: lib
|
||||
// FILE: Typography.kt
|
||||
object Typography {
|
||||
const val ellipsis: Char = 'O'
|
||||
}
|
||||
|
||||
// MODULE: main(lib)
|
||||
// FILE: main.kt
|
||||
class A {
|
||||
private companion object {
|
||||
fun String.orEllipsis(): String {
|
||||
return ellipsis
|
||||
}
|
||||
|
||||
const val ellipsis = "${Typography.ellipsis}"
|
||||
}
|
||||
|
||||
object B {
|
||||
fun box() = "".orEllipsis()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return A.B.box() + "K"
|
||||
}
|
||||
+6
@@ -7026,6 +7026,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
|
||||
+6
@@ -7026,6 +7026,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
|
||||
+5
@@ -5355,6 +5355,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java
Generated
+5
@@ -4738,6 +4738,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
|
||||
Generated
+5
@@ -4195,6 +4195,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
|
||||
Generated
+5
@@ -4195,6 +4195,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonTrue.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
|
||||
js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/wasm/semantics/IrCodegenBoxWasmTestGenerated.java
Generated
+5
@@ -3021,6 +3021,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
|
||||
runTest("compiler/testData/codegen/box/constants/comparisonFalse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constValFromAnotherModuleInConsVal.kt")
|
||||
public void testConstValFromAnotherModuleInConsVal() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constValFromAnotherModuleInConsVal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("constantsInWhen.kt")
|
||||
public void testConstantsInWhen() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/constants/constantsInWhen.kt");
|
||||
|
||||
Reference in New Issue
Block a user