update recorded EXPRESSION_TYPE of call expression

after type parameter inference completion
This commit is contained in:
Svetlana Isakova
2013-08-01 16:07:26 +04:00
parent e2f681c587
commit 051055896d
3 changed files with 9 additions and 32 deletions
@@ -274,21 +274,14 @@ public class BindingContextUtils {
trace.report(AMBIGUOUS_LABEL.on(targetLabel)); trace.report(AMBIGUOUS_LABEL.on(targetLabel));
} }
public static void recordExpressionType( public static void updateRecordedType(
@NotNull JetExpression expression, @NotNull BindingTrace trace, @Nullable JetType type,
@NotNull JetScope resolutionScope, @NotNull JetTypeInfo result @NotNull JetExpression expression,
@NotNull BindingTrace trace
) { ) {
JetType type = result.getType(); if (type == null) return;
if (type != null) { trace.record(BindingContext.EXPRESSION_TYPE, expression, type);
trace.record(BindingContext.EXPRESSION_TYPE, expression, type);
}
trace.record(BindingContext.PROCESSED, expression); 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 @Nullable
@@ -367,7 +367,7 @@ public class CandidateResolver {
type = completeNestedCallsInference(contextForArgument); type = completeNestedCallsInference(contextForArgument);
checkValueArgumentTypes(contextForArgument); checkValueArgumentTypes(contextForArgument);
} }
BindingContextUtils.updateRecordedType(type, expression, context.trace);
DataFlowUtils.checkType(type, expression, contextForArgument); DataFlowUtils.checkType(type, expression, contextForArgument);
} }
@@ -397,7 +397,8 @@ public class CandidateResolver {
if (type != null && !type.getConstructor().isDenotable()) { if (type != null && !type.getConstructor().isDenotable()) {
if (type.getConstructor() instanceof NumberValueTypeConstructor) { if (type.getConstructor() instanceof NumberValueTypeConstructor) {
NumberValueTypeConstructor constructor = (NumberValueTypeConstructor) type.getConstructor(); 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; return type;
@@ -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;
}
} }