more tests for KT-1897

#KT-1897 fixed
This commit is contained in:
Svetlana Isakova
2012-05-11 14:24:30 +04:00
parent 3528822d7e
commit 696df0eb9b
3 changed files with 31 additions and 11 deletions
@@ -416,7 +416,7 @@ public class CallResolver {
checkTypesWithNoCallee(context.toBasic()); checkTypesWithNoCallee(context.toBasic());
return; return;
} }
checkUnknownArgumentTypes(context.toBasic(), unmappedArguments); checkUnmappedArgumentTypes(context.toBasic(), unmappedArguments);
} }
List<JetTypeProjection> jetTypeArguments = context.call.getTypeArguments(); List<JetTypeProjection> jetTypeArguments = context.call.getTypeArguments();
@@ -612,8 +612,8 @@ public class CallResolver {
} }
} }
private void checkUnknownArgumentTypes(BasicResolutionContext context, Set<ValueArgument> unknownArguments) { private void checkUnmappedArgumentTypes(BasicResolutionContext context, Set<ValueArgument> unmappedArguments) {
for (ValueArgument valueArgument : unknownArguments) { for (ValueArgument valueArgument : unmappedArguments) {
JetExpression argumentExpression = valueArgument.getArgumentExpression(); JetExpression argumentExpression = valueArgument.getArgumentExpression();
if (argumentExpression != null) { if (argumentExpression != null) {
expressionTypingServices.getType(context.scope, argumentExpression, NO_EXPECTED_TYPE, context.trace); expressionTypingServices.getType(context.scope, argumentExpression, NO_EXPECTED_TYPE, context.trace);
@@ -101,7 +101,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
if (valueParameterDescriptor == null) { if (valueParameterDescriptor == null) {
temporaryTrace.report(NAMED_PARAMETER_NOT_FOUND.on(nameReference)); temporaryTrace.report(NAMED_PARAMETER_NOT_FOUND.on(nameReference));
unmappedArguments.add(valueArgument); unmappedArguments.add(valueArgument);
status = ERROR; status = WEAK_ERROR;
} }
else { else {
temporaryTrace.record(REFERENCE_TARGET, nameReference, valueParameterDescriptor); temporaryTrace.record(REFERENCE_TARGET, nameReference, valueParameterDescriptor);
@@ -116,14 +116,14 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
} }
if (somePositioned) { if (somePositioned) {
temporaryTrace.report(MIXING_NAMED_AND_POSITIONED_ARGUMENTS.on(nameReference)); temporaryTrace.report(MIXING_NAMED_AND_POSITIONED_ARGUMENTS.on(nameReference));
status = ERROR; status = WEAK_ERROR;
} }
} }
else { else {
somePositioned = true; somePositioned = true;
if (someNamed) { if (someNamed) {
temporaryTrace.report(MIXING_NAMED_AND_POSITIONED_ARGUMENTS.on(valueArgument.asElement())); temporaryTrace.report(MIXING_NAMED_AND_POSITIONED_ARGUMENTS.on(valueArgument.asElement()));
status = ERROR; status = WEAK_ERROR;
} }
else { else {
int parameterCount = valueParameters.size(); int parameterCount = valueParameters.size();
@@ -147,7 +147,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
else { else {
temporaryTrace.report(TOO_MANY_ARGUMENTS.on(valueArgument.asElement(), candidate)); temporaryTrace.report(TOO_MANY_ARGUMENTS.on(valueArgument.asElement(), candidate));
unmappedArguments.add(valueArgument); unmappedArguments.add(valueArgument);
status = WEAK_ERROR; status = ERROR;
} }
} }
} }
@@ -179,7 +179,7 @@ import static org.jetbrains.jet.lang.resolve.calls.ValueArgumentsToParametersMap
else { else {
if (!usedParameters.add(valueParameterDescriptor)) { if (!usedParameters.add(valueParameterDescriptor)) {
temporaryTrace.report(TOO_MANY_ARGUMENTS.on(possiblyLabeledFunctionLiteral, candidate)); temporaryTrace.report(TOO_MANY_ARGUMENTS.on(possiblyLabeledFunctionLiteral, candidate));
status = ERROR; status = WEAK_ERROR;
} }
else { else {
status = status.compose(put(candidateCall, valueParameterDescriptor, CallMaker.makeValueArgument(functionLiteral), varargs)); 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++) { for (int i = 1; i < functionLiteralArguments.size(); i++) {
JetExpression argument = functionLiteralArguments.get(i); JetExpression argument = functionLiteralArguments.get(i);
temporaryTrace.report(MANY_FUNCTION_LITERAL_ARGUMENTS.on(argument)); 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 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() { 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(<!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!>{}<!>
} }