generate more correct bytecode for casting Unit to other types

This commit is contained in:
Dmitry Jemerov
2015-03-24 19:46:02 +01:00
parent 9d618ca767
commit bb1410b20a
5 changed files with 36 additions and 4 deletions
@@ -3918,7 +3918,10 @@ The "returned" value of try expression with no finally is either the last expres
public Unit invoke(InstructionAdapter v) {
value.put(boxType(value.type), v);
if (opToken != JetTokens.AS_SAFE) {
if (value.type == Type.VOID_TYPE) {
v.aconst(null);
}
else if (opToken != JetTokens.AS_SAFE) {
if (!TypeUtils.isNullableType(rightType)) {
v.dup();
Label nonnull = new Label();
@@ -3931,9 +3934,6 @@ 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);