JVM_IR KT-43242 generate switch subject as primitive 'int'
This commit is contained in:
Generated
+5
@@ -32257,6 +32257,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT
|
|||||||
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt43242.kt")
|
||||||
|
public void testKt43242() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt43242.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
||||||
|
|||||||
+3
-1
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.ir.types.*
|
|||||||
import org.jetbrains.kotlin.ir.util.dump
|
import org.jetbrains.kotlin.ir.util.dump
|
||||||
import org.jetbrains.kotlin.ir.util.isTrueConst
|
import org.jetbrains.kotlin.ir.util.isTrueConst
|
||||||
import org.jetbrains.org.objectweb.asm.Label
|
import org.jetbrains.org.objectweb.asm.Label
|
||||||
|
import org.jetbrains.org.objectweb.asm.Type
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
|
||||||
// TODO: eliminate the temporary variable
|
// TODO: eliminate the temporary variable
|
||||||
@@ -367,7 +368,8 @@ class SwitchGenerator(private val expression: IrWhen, private val data: BlockInf
|
|||||||
// information for the subject as the `when` line number has already been
|
// information for the subject as the `when` line number has already been
|
||||||
// emitted.
|
// emitted.
|
||||||
codegen.noLineNumberScope {
|
codegen.noLineNumberScope {
|
||||||
subject.accept(codegen, data).materialize()
|
val subjectValue = subject.accept(codegen, data)
|
||||||
|
subjectValue.materializeAt(Type.INT_TYPE, subjectValue.irType)
|
||||||
}
|
}
|
||||||
genIntSwitch(cases)
|
genIntSwitch(cases)
|
||||||
}
|
}
|
||||||
|
|||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// FILE: kt43242.kt
|
||||||
|
|
||||||
|
fun fromJson() {
|
||||||
|
test = Bar().fromJson()?.let {
|
||||||
|
when (it) {
|
||||||
|
0 -> false
|
||||||
|
1 -> true
|
||||||
|
else -> true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var test: Any? = "xxx"
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
fromJson()
|
||||||
|
return if (test != null) "Fail: $test" else "OK"
|
||||||
|
}
|
||||||
|
|
||||||
|
// FILE: Bar.java
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
public class Bar {
|
||||||
|
public final @Nullable Integer fromJson() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
+5
@@ -34028,6 +34028,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt43242.kt")
|
||||||
|
public void testKt43242() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt43242.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
||||||
|
|||||||
+5
@@ -31662,6 +31662,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt43242.kt")
|
||||||
|
public void testKt43242() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt43242.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
||||||
|
|||||||
+5
@@ -32257,6 +32257,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
runTest("compiler/testData/codegen/box/when/kt2466.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt43242.kt")
|
||||||
|
public void testKt43242() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/when/kt43242.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("kt5307.kt")
|
@TestMetadata("kt5307.kt")
|
||||||
public void testKt5307() throws Exception {
|
public void testKt5307() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
runTest("compiler/testData/codegen/box/when/kt5307.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user