diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java index 557f4f056fa..fba6f538d67 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/ArgumentTypeResolver.java @@ -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 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()); + } + } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index 9a605b3ece4..991735d9120 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -426,6 +426,10 @@ public class CallResolver { debugInfo.set(ResolutionDebugInfo.TASKS, prioritizedTasks); + if (context.checkArguments == CheckValueArgumentsMode.ENABLED) { + argumentTypeResolver.analyzeArgumentsAndRecordTypes(context); + } + TemporaryBindingTrace traceForFirstNonemptyCandidateSet = null; OverloadResolutionResultsImpl resultsForFirstNonemptyCandidateSet = null; for (ResolutionTask task : prioritizedTasks) { diff --git a/compiler/testData/diagnostics/tests/Basic.kt b/compiler/testData/diagnostics/tests/Basic.kt index 0194bdfba91..68cd06d9776 100644 --- a/compiler/testData/diagnostics/tests/Basic.kt +++ b/compiler/testData/diagnostics/tests/Basic.kt @@ -9,7 +9,7 @@ fun test() : Int { } class A() { - val x : Int = foo1(xx) + val x : Int = foo1(xx) } fun foo1() {} diff --git a/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt b/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt index 84a5ec8e136..52e3624136f 100644 --- a/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt +++ b/compiler/testData/diagnostics/tests/annotations/AmbigiousAnnotationConstructor.kt @@ -2,4 +2,4 @@ import java.util.ArrayList ArrayList(1, 1) fun b() {} Xoo(x) fun c() {} -Deprecated(x) fun a() {} \ No newline at end of file +Deprecated(x) fun a() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/checkArguments/kt1897_diagnostic_part.kt b/compiler/testData/diagnostics/tests/checkArguments/kt1897_diagnostic_part.kt index a285a9e0f0c..44c0419f47d 100644 --- a/compiler/testData/diagnostics/tests/checkArguments/kt1897_diagnostic_part.kt +++ b/compiler/testData/diagnostics/tests/checkArguments/kt1897_diagnostic_part.kt @@ -8,11 +8,11 @@ fun foo(i: Int, s: String) {} fun test() { - bar(xx) + bar(xx) bar { } - foo("", 1, xx) + foo("", 1, xx) foo(r = xx, i = "", s = "")