From 051055896d31bbccdf051bcab5dc69d3cf21da8b Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Thu, 1 Aug 2013 16:07:26 +0400 Subject: [PATCH] update recorded EXPRESSION_TYPE of call expression after type parameter inference completion --- .../jet/lang/resolve/BindingContextUtils.java | 19 ++++++------------- .../lang/resolve/calls/CandidateResolver.java | 5 +++-- .../lang/resolve/constants/ConstantUtils.java | 17 ----------------- 3 files changed, 9 insertions(+), 32 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java index 2c89278d6bc..47d0d26472b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -274,21 +274,14 @@ public class BindingContextUtils { trace.report(AMBIGUOUS_LABEL.on(targetLabel)); } - public static void recordExpressionType( - @NotNull JetExpression expression, @NotNull BindingTrace trace, - @NotNull JetScope resolutionScope, @NotNull JetTypeInfo result + public static void updateRecordedType( + @Nullable JetType type, + @NotNull JetExpression expression, + @NotNull BindingTrace trace ) { - JetType type = result.getType(); - if (type != null) { - trace.record(BindingContext.EXPRESSION_TYPE, expression, type); - } + if (type == null) return; + trace.record(BindingContext.EXPRESSION_TYPE, expression, type); trace.record(BindingContext.PROCESSED, expression); - if (result.getDataFlowInfo() != DataFlowInfo.EMPTY) { - trace.record(BindingContext.EXPRESSION_DATA_FLOW_INFO, expression, result.getDataFlowInfo()); - } - if (!isExpressionWithValidReference(expression, trace.getBindingContext())) { - trace.record(BindingContext.RESOLUTION_SCOPE, expression, resolutionScope); - } } @Nullable diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java index e8d301adac1..f7ad1c1e06b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java @@ -367,7 +367,7 @@ public class CandidateResolver { type = completeNestedCallsInference(contextForArgument); checkValueArgumentTypes(contextForArgument); } - + BindingContextUtils.updateRecordedType(type, expression, context.trace); DataFlowUtils.checkType(type, expression, contextForArgument); } @@ -397,7 +397,8 @@ public class CandidateResolver { if (type != null && !type.getConstructor().isDenotable()) { if (type.getConstructor() instanceof NumberValueTypeConstructor) { NumberValueTypeConstructor constructor = (NumberValueTypeConstructor) type.getConstructor(); - type = ConstantUtils.updateConstantValueType(constructor, context.expectedType, expression, context); + type = TypeUtils.getPrimitiveNumberType(constructor, context.expectedType); + BindingContextUtils.updateRecordedType(type, expression, context.trace); } } return type; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/ConstantUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/ConstantUtils.java index 86485355c15..ab3ea5ddb24 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/ConstantUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/constants/ConstantUtils.java @@ -68,21 +68,4 @@ public class ConstantUtils { } } } - - public static JetType updateConstantValueType( - @NotNull NumberValueTypeConstructor numberValueTypeConstructor, - @NotNull JetType expectedType, - @NotNull JetExpression expression, - @NotNull ResolutionContext context - ) { - JetTypeInfo recordedTypeInfo = BindingContextUtils.getRecordedTypeInfo(expression, context.trace.getBindingContext()); - assert recordedTypeInfo != null : "Expression " + expression + " should have been analyzed"; - JetScope resolutionScope = context.trace.get(BindingContext.RESOLUTION_SCOPE, expression); - assert resolutionScope != null : "Expression " + expression + " should have been analyzed"; - - JetType type = TypeUtils.getPrimitiveNumberType(numberValueTypeConstructor, expectedType); - BindingContextUtils.recordExpressionType(expression, context.trace, resolutionScope, - JetTypeInfo.create(type, recordedTypeInfo.getDataFlowInfo())); - return type; - } }