correctly generate safe casts from Unit type
#KT-4494 fixed
This commit is contained in:
@@ -3840,6 +3840,9 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
v.mark(nonnull);
|
||||
}
|
||||
}
|
||||
else if (value.type == Type.VOID_TYPE) {
|
||||
v.aconst(null);
|
||||
}
|
||||
else {
|
||||
v.dup();
|
||||
generateInstanceOfInstruction(rightType);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
fun foo() {}
|
||||
|
||||
fun bar(): Int? = foo() as? Int
|
||||
|
||||
fun box(): String {
|
||||
return if (bar() == null) "OK" else "fail"
|
||||
}
|
||||
+6
@@ -930,6 +930,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/notIs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("unitNullableCast.kt")
|
||||
public void testUnitNullableCast() throws Exception {
|
||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/unitNullableCast.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/codegen/box/classes")
|
||||
|
||||
Reference in New Issue
Block a user