analyze all arguments with unknown expected type

in the beginning of call resolution process
This commit is contained in:
Svetlana Isakova
2013-08-16 18:32:20 +04:00
parent c8fc2c882d
commit 30b0a72c6b
5 changed files with 25 additions and 4 deletions
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.context.CheckValueArgumentsMode;
import org.jetbrains.jet.lang.resolve.calls.context.ResolutionContext;
import org.jetbrains.jet.lang.resolve.calls.context.ContextDependency;
import org.jetbrains.jet.lang.resolve.calls.model.MutableDataFlowInfoForArguments;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl;
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedValueArgument;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
@@ -231,4 +232,20 @@ public class ArgumentTypeResolver {
}
return defaultValue;
}
public <D extends CallableDescriptor> void analyzeArgumentsAndRecordTypes(
@NotNull CallResolutionContext<?> context
) {
MutableDataFlowInfoForArguments infoForArguments = context.dataFlowInfoForArguments;
infoForArguments.setInitialDataFlowInfo(context.dataFlowInfo);
for (ValueArgument argument : context.call.getValueArguments()) {
JetExpression expression = argument.getArgumentExpression();
if (expression == null) continue;
CallResolutionContext<?> newContext = context.replaceDataFlowInfo(infoForArguments.getInfo(argument));
JetTypeInfo typeInfoForCall = getArgumentTypeInfo(expression, newContext, SKIP_FUNCTION_ARGUMENTS);
infoForArguments.updateInfo(argument, typeInfoForCall.getDataFlowInfo());
}
}
}
@@ -426,6 +426,10 @@ public class CallResolver {
debugInfo.set(ResolutionDebugInfo.TASKS, prioritizedTasks);
if (context.checkArguments == CheckValueArgumentsMode.ENABLED) {
argumentTypeResolver.analyzeArgumentsAndRecordTypes(context);
}
TemporaryBindingTrace traceForFirstNonemptyCandidateSet = null;
OverloadResolutionResultsImpl<F> resultsForFirstNonemptyCandidateSet = null;
for (ResolutionTask<D, F> task : prioritizedTasks) {
+1 -1
View File
@@ -9,7 +9,7 @@ fun test() : Int {
}
class A() {
val x : Int = <!TYPE_MISMATCH!>foo1(<!TOO_MANY_ARGUMENTS, UNRESOLVED_REFERENCE!>xx<!>)<!>
val x : Int = <!TYPE_MISMATCH!>foo1(<!UNRESOLVED_REFERENCE, TOO_MANY_ARGUMENTS!>xx<!>)<!>
}
fun foo1() {}
@@ -2,4 +2,4 @@ import java.util.ArrayList
<!NONE_APPLICABLE!>ArrayList<!><Int>(1, 1) fun b() {}
<!UNRESOLVED_REFERENCE!>Xoo<!>(<!UNRESOLVED_REFERENCE!>x<!>) fun c() {}
<!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Deprecated<!>(<!TOO_MANY_ARGUMENTS, UNRESOLVED_REFERENCE!>x<!>) fun a() {}
<!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Deprecated<!>(<!UNRESOLVED_REFERENCE, TOO_MANY_ARGUMENTS!>x<!>) fun a() {}
@@ -8,11 +8,11 @@ fun foo(<!UNUSED_PARAMETER!>i<!>: Int, <!UNUSED_PARAMETER!>s<!>: String) {}
fun test() {
bar(<!TOO_MANY_ARGUMENTS, UNRESOLVED_REFERENCE!>xx<!>)
bar(<!UNRESOLVED_REFERENCE, TOO_MANY_ARGUMENTS!>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<!>, <!UNRESOLVED_REFERENCE, TOO_MANY_ARGUMENTS!>xx<!>)
foo(<!NAMED_PARAMETER_NOT_FOUND!>r<!> = <!UNRESOLVED_REFERENCE!>xx<!>, i = <!TYPE_MISMATCH!>""<!>, s = "")