Fixed the call completer

to update the type of the argument expression correctly
This commit is contained in:
Svetlana Isakova
2015-10-21 14:42:39 +03:00
parent 06e90cf6a1
commit 9877fe1a26
4 changed files with 30 additions and 4 deletions
@@ -149,7 +149,7 @@ public class ArgumentTypeResolver {
private void checkArgumentTypeWithNoCallee(CallResolutionContext<?> context, KtExpression argumentExpression) {
expressionTypingServices.getTypeInfo(argumentExpression, context.replaceExpectedType(NO_EXPECTED_TYPE));
updateResultArgumentTypeIfNotDenotable(context, argumentExpression);
updateResultArgumentTypeIfNotDenotable(context, argumentExpression, null);
}
public static boolean isFunctionLiteralArgument(
@@ -349,9 +349,10 @@ public class ArgumentTypeResolver {
@Nullable
public KotlinType updateResultArgumentTypeIfNotDenotable(
@NotNull ResolutionContext context,
@NotNull KtExpression expression
@NotNull KtExpression expression,
@Nullable KotlinType argumentType
) {
KotlinType type = context.trace.getType(expression);
KotlinType type = (argumentType != null) ? argumentType : context.trace.getType(expression);
if (type != null && !type.getConstructor().isDenotable()) {
if (type.getConstructor() instanceof IntegerValueTypeConstructor) {
IntegerValueTypeConstructor constructor = (IntegerValueTypeConstructor) type.getConstructor();
@@ -251,7 +251,7 @@ public class CallCompleter(
// For the cases like 'foo(1)' the type of '1' depends on expected type (it can be Int, Byte, etc.),
// so while the expected type is not known, it's IntegerValueType(1), and should be updated when the expected type is known.
if (recordedType != null && !recordedType.getConstructor().isDenotable()) {
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression)
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression, updatedType)
}
updatedType = updateRecordedTypeForArgument(updatedType, recordedType, expression, context.trace)