Fixed the call completer
to update the type of the argument expression correctly
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user