[JVM_IR] Recursively perform constant lowering.

Otherwise constants in child expressions are not transformed.

^KT-47716 Fixed.
This commit is contained in:
Mads Ager
2021-07-19 13:03:37 +02:00
committed by Alexander Udalov
parent 2877f1cabe
commit 6436a1686d
10 changed files with 56 additions and 0 deletions
@@ -42460,6 +42460,12 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@Test
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@Test
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
@@ -52,6 +52,7 @@ class ConstLowering(val context: JvmBackendContext) : IrElementTransformerVoid()
private fun IrExpression.lowerConstRead(receiver: IrExpression?, field: IrField?): IrExpression? {
val value = field?.constantValue() ?: return null
transformChildrenVoid()
val resultExpression = if (context.state.shouldInlineConstVals)
value.copyWithOffsets(startOffset, endOffset)
else
+12
View File
@@ -0,0 +1,12 @@
// IGNORE_BACKEND: WASM
// WITH_RUNTIME
fun box(): String {
val r =
try {
ULong
} finally {
UInt.MAX_VALUE
}.MAX_VALUE
return if (r == ULong.MAX_VALUE) "OK" else "FAIL"
}
@@ -42418,6 +42418,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@Test
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@Test
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
@@ -42460,6 +42460,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@Test
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@Test
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
@@ -34180,6 +34180,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/literalEqualsNullableUnsigned.kt");
@@ -28460,6 +28460,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/literalEqualsNullableUnsigned.kt");
@@ -27866,6 +27866,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/literalEqualsNullableUnsigned.kt");
@@ -27826,6 +27826,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/literalEqualsNullableUnsigned.kt");
@@ -15849,6 +15849,11 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest
runTest("compiler/testData/codegen/box/unsignedTypes/kt43286a.kt");
}
@TestMetadata("kt47716.kt")
public void testKt47716() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/kt47716.kt");
}
@TestMetadata("literalEqualsNullableUnsigned.kt")
public void testLiteralEqualsNullableUnsigned() throws Exception {
runTest("compiler/testData/codegen/box/unsignedTypes/literalEqualsNullableUnsigned.kt");