Fixed 'OnlyInputTypes' working with number types

This commit is contained in:
Svetlana Isakova
2015-10-21 15:09:05 +03:00
parent 9877fe1a26
commit b24cb2a326
4 changed files with 27 additions and 17 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, null);
updateResultArgumentTypeIfNotDenotable(context, argumentExpression);
}
public static boolean isFunctionLiteralArgument(
@@ -349,10 +349,9 @@ public class ArgumentTypeResolver {
@Nullable
public KotlinType updateResultArgumentTypeIfNotDenotable(
@NotNull ResolutionContext context,
@NotNull KtExpression expression,
@Nullable KotlinType argumentType
@NotNull KtExpression expression
) {
KotlinType type = (argumentType != null) ? argumentType : context.trace.getType(expression);
KotlinType type = context.trace.getType(expression);
if (type != null && !type.getConstructor().isDenotable()) {
if (type.getConstructor() instanceof IntegerValueTypeConstructor) {
IntegerValueTypeConstructor constructor = (IntegerValueTypeConstructor) type.getConstructor();
@@ -361,6 +360,6 @@ public class ArgumentTypeResolver {
return primitiveType;
}
}
return type;
return null;
}
}
@@ -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)
updatedType = argumentTypeResolver.updateResultArgumentTypeIfNotDenotable(context, expression) ?: updatedType
}
updatedType = updateRecordedTypeForArgument(updatedType, recordedType, expression, context.trace)