diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index b55cfd3d29a..06d07d9554c 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -2212,12 +2212,8 @@ public class ExpressionCodegen extends JetVisitor implem gen(expr, receiverType); if (!receiverJetType.isNullable()) { StackValue propValue = genQualified(StackValue.onStack(receiverType), expression.getSelectorExpression()); - Type type = propValue.type; + Type type = boxType(propValue.type); propValue.put(type, v); - if (isPrimitive(type) && !type.equals(Type.VOID_TYPE)) { - StackValue.valueOf(v, type); - type = boxType(type); - } return StackValue.onStack(type); } @@ -2227,17 +2223,13 @@ public class ExpressionCodegen extends JetVisitor implem v.dup(); v.ifnull(ifnull); StackValue propValue = genQualified(StackValue.onStack(receiverType), expression.getSelectorExpression()); - Type type = propValue.type; + Type type = boxType(propValue.type); propValue.put(type, v); - if (isPrimitive(type) && !type.equals(Type.VOID_TYPE)) { - StackValue.valueOf(v, type); - type = boxType(type); - } v.goTo(end); v.mark(ifnull); v.pop(); - if (!propValue.type.equals(Type.VOID_TYPE)) { + if (!type.equals(Type.VOID_TYPE)) { v.aconst(null); } v.mark(end); @@ -2394,12 +2386,10 @@ public class ExpressionCodegen extends JetVisitor implem } if (isPrimitive(leftType) != isPrimitive(rightType)) { - gen(left, leftType); - StackValue.valueOf(v, leftType); leftType = boxType(leftType); - gen(right, rightType); - StackValue.valueOf(v, rightType); + gen(left, leftType); rightType = boxType(rightType); + gen(right, rightType); } else { gen(left, leftType); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java index 6f684ee67d2..d2d487da7b1 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java @@ -766,12 +766,9 @@ public class FunctionCodegen extends GenerationStateAware { iv.invokevirtual(state.getTypeMapper().mapType( (ClassDescriptor) owner.getContextDescriptor()).getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor()); - if (isPrimitive(jvmSignature.getReturnType()) && !isPrimitive(overridden.getReturnType())) { - StackValue.valueOf(iv, jvmSignature.getReturnType()); - } - if (jvmSignature.getReturnType() == Type.VOID_TYPE) { - iv.aconst(null); - } + + StackValue.onStack(jvmSignature.getReturnType()).put(overridden.getReturnType(), iv); + iv.areturn(overridden.getReturnType()); endVisit(mv, "bridge method", callableDescriptorToDeclaration(state.getBindingContext(), functionDescriptor)); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java index 47f76c08bc2..270553202ad 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java @@ -54,19 +54,6 @@ public abstract class StackValue { this.type = type; } - public static void valueOf(InstructionAdapter instructionAdapter, final Type type) { - if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY) { - return; - } - if (type == Type.VOID_TYPE) { - instructionAdapter.aconst(null); - } - else { - Type boxed = boxType(type); - instructionAdapter.invokestatic(boxed.getInternalName(), "valueOf", "(" + type.getDescriptor() + ")" + boxed.getDescriptor()); - } - } - /** * Put this value to the top of the stack. */