more tests for KT-1897
#KT-1897 fixed
This commit is contained in:
@@ -416,7 +416,7 @@ public class CallResolver {
|
||||
checkTypesWithNoCallee(context.toBasic());
|
||||
return;
|
||||
}
|
||||
checkUnknownArgumentTypes(context.toBasic(), unmappedArguments);
|
||||
checkUnmappedArgumentTypes(context.toBasic(), unmappedArguments);
|
||||
}
|
||||
|
||||
List<JetTypeProjection> jetTypeArguments = context.call.getTypeArguments();
|
||||
@@ -612,8 +612,8 @@ public class CallResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUnknownArgumentTypes(BasicResolutionContext context, Set<ValueArgument> unknownArguments) {
|
||||
for (ValueArgument valueArgument : unknownArguments) {
|
||||
private void checkUnmappedArgumentTypes(BasicResolutionContext context, Set<ValueArgument> unmappedArguments) {
|
||||
for (ValueArgument valueArgument : unmappedArguments) {
|
||||
JetExpression argumentExpression = valueArgument.getArgumentExpression();
|
||||
if (argumentExpression != null) {
|
||||
expressionTypingServices.getType(context.scope, argumentExpression, NO_EXPECTED_TYPE, context.trace);
|
||||
|
||||
+6
-6
@@ -101,7 +101,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
if (valueParameterDescriptor == null) {
|
||||
temporaryTrace.report(NAMED_PARAMETER_NOT_FOUND.on(nameReference));
|
||||
unmappedArguments.add(valueArgument);
|
||||
status = ERROR;
|
||||
status = WEAK_ERROR;
|
||||
}
|
||||
else {
|
||||
temporaryTrace.record(REFERENCE_TARGET, nameReference, valueParameterDescriptor);
|
||||
@@ -116,14 +116,14 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
}
|
||||
if (somePositioned) {
|
||||
temporaryTrace.report(MIXING_NAMED_AND_POSITIONED_ARGUMENTS.on(nameReference));
|
||||
status = ERROR;
|
||||
status = WEAK_ERROR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
somePositioned = true;
|
||||
if (someNamed) {
|
||||
temporaryTrace.report(MIXING_NAMED_AND_POSITIONED_ARGUMENTS.on(valueArgument.asElement()));
|
||||
status = ERROR;
|
||||
status = WEAK_ERROR;
|
||||
}
|
||||
else {
|
||||
int parameterCount = valueParameters.size();
|
||||
@@ -147,7 +147,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
else {
|
||||
temporaryTrace.report(TOO_MANY_ARGUMENTS.on(valueArgument.asElement(), candidate));
|
||||
unmappedArguments.add(valueArgument);
|
||||
status = WEAK_ERROR;
|
||||
status = ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +179,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
else {
|
||||
if (!usedParameters.add(valueParameterDescriptor)) {
|
||||
temporaryTrace.report(TOO_MANY_ARGUMENTS.on(possiblyLabeledFunctionLiteral, candidate));
|
||||
status = ERROR;
|
||||
status = WEAK_ERROR;
|
||||
}
|
||||
else {
|
||||
status = status.compose(put(candidateCall, valueParameterDescriptor, CallMaker.makeValueArgument(functionLiteral), varargs));
|
||||
@@ -190,7 +190,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
|
||||
for (int i = 1; i < functionLiteralArguments.size(); i++) {
|
||||
JetExpression argument = functionLiteralArguments.get(i);
|
||||
temporaryTrace.report(MANY_FUNCTION_LITERAL_ARGUMENTS.on(argument));
|
||||
status = ERROR;
|
||||
status = WEAK_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,28 @@
|
||||
//KT-1897 When call cannot be resolved to any function, save information about types of arguments
|
||||
|
||||
package a
|
||||
|
||||
fun foo(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>s<!>: String) {
|
||||
}
|
||||
fun bar() {}
|
||||
|
||||
fun foo(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>s<!>: String) {}
|
||||
|
||||
fun test() {
|
||||
|
||||
bar(<!TOO_MANY_ARGUMENTS, UNRESOLVED_REFERENCE!>xx<!>)
|
||||
|
||||
bar <!TOO_MANY_ARGUMENTS, DANGLING_FUNCTION_LITERAL_ARGUMENT_SUSPECTED!>{ }<!>
|
||||
|
||||
foo(<!TYPE_MISMATCH!>""<!>, <!ERROR_COMPILE_TIME_VALUE!>1<!>, <!TOO_MANY_ARGUMENTS, UNRESOLVED_REFERENCE!>xx<!>)
|
||||
|
||||
foo(<!NAMED_PARAMETER_NOT_FOUND!>r<!> = <!UNRESOLVED_REFERENCE!>xx<!>, i = <!TYPE_MISMATCH!>""<!>, s = "")
|
||||
|
||||
foo(i = 1, <!ARGUMENT_PASSED_TWICE!>i<!> = 1, s = <!ERROR_COMPILE_TIME_VALUE!>11<!>)
|
||||
|
||||
foo(<!TYPE_MISMATCH!>""<!>, <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>s<!> = <!ERROR_COMPILE_TIME_VALUE!>2<!>)
|
||||
|
||||
foo(i = <!TYPE_MISMATCH!>""<!>, s = <!ERROR_COMPILE_TIME_VALUE!>2<!>, <!MIXING_NAMED_AND_POSITIONED_ARGUMENTS!>33<!>)
|
||||
|
||||
foo(<!TYPE_MISMATCH!>""<!>, <!ERROR_COMPILE_TIME_VALUE!>1<!>) <!TOO_MANY_ARGUMENTS!>{}<!>
|
||||
|
||||
foo(<!TYPE_MISMATCH!>""<!>, <!ERROR_COMPILE_TIME_VALUE!>1<!>) <!TOO_MANY_ARGUMENTS!>{}<!> <!MANY_FUNCTION_LITERAL_ARGUMENTS!>{}<!>
|
||||
}
|
||||
Reference in New Issue
Block a user