From fc3db8db3874b21124ecdd66c473e46b10bab080 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 5 May 2014 17:21:45 +0400 Subject: [PATCH] Minor, get rid of ExpressionCodegen.asmTypeOrVoid() --- .../jetbrains/jet/codegen/ExpressionCodegen.java | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 85970ccf754..525258ea27a 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -317,7 +317,8 @@ public class ExpressionCodegen extends JetVisitor implem } @NotNull - private Type asmTypeOrVoid(@Nullable JetType type) { + public Type expressionType(JetExpression expression) { + JetType type = bindingContext.get(EXPRESSION_TYPE, expression); return type == null ? Type.VOID_TYPE : asmType(type); } @@ -2406,11 +2407,6 @@ public class ExpressionCodegen extends JetVisitor implem } } - @NotNull - public Type expressionType(JetExpression expr) { - return asmTypeOrVoid(bindingContext.get(EXPRESSION_TYPE, expr)); - } - public int indexOfLocal(JetReferenceExpression lhs) { DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, lhs); if (isVarCapturedInClosure(bindingContext, declarationDescriptor)) { @@ -3301,7 +3297,7 @@ public class ExpressionCodegen extends JetVisitor implem public StackValue visitArrayAccessExpression(@NotNull JetArrayAccessExpression expression, StackValue receiver) { JetExpression array = expression.getArrayExpression(); JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, array); - Type arrayType = asmTypeOrVoid(type); + Type arrayType = expressionType(array); List indices = expression.getIndexExpressions(); FunctionDescriptor operationDescriptor = (FunctionDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, expression); assert operationDescriptor != null; @@ -3628,8 +3624,7 @@ The "returned" value of try expression with no finally is either the last expres public StackValue generateWhenExpression(JetWhenExpression expression, boolean isStatement) { JetExpression expr = expression.getSubjectExpression(); - JetType subjectJetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, expr); - Type subjectType = asmTypeOrVoid(subjectJetType); + Type subjectType = expressionType(expr); Type resultType = isStatement ? Type.VOID_TYPE : expressionType(expression);