Fix VerifyError for 'when' of type 'Unit?'
This commit is contained in:
@@ -234,8 +234,10 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (toType.equals(JET_UNIT_TYPE)) {
|
else if (toType.equals(JET_UNIT_TYPE)) {
|
||||||
pop(v, fromType);
|
if (!fromType.equals(getType(Void.class))) {
|
||||||
putUnitInstance(v);
|
pop(v, fromType);
|
||||||
|
putUnitInstance(v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (toType.getSort() == Type.ARRAY) {
|
else if (toType.getSort() == Type.ARRAY) {
|
||||||
v.checkcast(toType);
|
v.checkcast(toType);
|
||||||
@@ -431,9 +433,7 @@ public abstract class StackValue {
|
|||||||
v.aconst(value);
|
v.aconst(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value != null) {
|
coerceTo(type, v);
|
||||||
coerceTo(type, v);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fun foo() {}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
when ("A") {
|
||||||
|
"B" -> foo()
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
foo()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
fun foo() {}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
when ("A") {
|
||||||
|
"B" -> null
|
||||||
|
else -> foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
foo()
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
@@ -4812,6 +4812,16 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest("compiler/testData/codegen/box/unit/nullableUnit.kt");
|
doTest("compiler/testData/codegen/box/unit/nullableUnit.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullableUnitInWhen1.kt")
|
||||||
|
public void testNullableUnitInWhen1() throws Exception {
|
||||||
|
doTest("compiler/testData/codegen/box/unit/nullableUnitInWhen1.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("nullableUnitInWhen2.kt")
|
||||||
|
public void testNullableUnitInWhen2() throws Exception {
|
||||||
|
doTest("compiler/testData/codegen/box/unit/nullableUnitInWhen2.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("unitClassObject.kt")
|
@TestMetadata("unitClassObject.kt")
|
||||||
public void testUnitClassObject() throws Exception {
|
public void testUnitClassObject() throws Exception {
|
||||||
doTest("compiler/testData/codegen/box/unit/unitClassObject.kt");
|
doTest("compiler/testData/codegen/box/unit/unitClassObject.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user