diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java index aa7325a237a..af700113278 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CandidateResolver.java @@ -321,10 +321,10 @@ public class CandidateResolver { return resolvedCall.getResultingDescriptor().getReturnType(); } - @Nullable - public JetType completeNestedCallsInference( + public void completeNestedCallsInference( @NotNull CallCandidateResolutionContext context ) { + if (context.call.getCallType() == Call.CallType.INVOKE) return; ResolvedCallImpl resolvedCall = context.candidateCall; for (Map.Entry entry : resolvedCall.getValueArguments().entrySet()) { ValueParameterDescriptor parameterDescriptor = entry.getKey(); @@ -335,7 +335,6 @@ public class CandidateResolver { } } recordReferenceForInvokeFunction(context); - return resolvedCall.getResultingDescriptor().getReturnType(); } private void completeInferenceForArgument( @@ -371,7 +370,8 @@ public class CandidateResolver { type = completeTypeInferenceDependentOnExpectedTypeForCall(contextForArgument, true); } else { - type = completeNestedCallsInference(contextForArgument); + completeNestedCallsInference(contextForArgument); + type = contextForArgument.candidateCall.getResultingDescriptor().getReturnType(); checkValueArgumentTypes(contextForArgument); } JetType result = BindingContextUtils.updateRecordedType( @@ -387,6 +387,7 @@ public class CandidateResolver { } public void completeNestedCallsForNotResolvedInvocation(@NotNull CallResolutionContext context, @NotNull Collection arguments) { + if (context.call.getCallType() == Call.CallType.INVOKE) return; if (context.checkArguments == CheckValueArgumentsMode.DISABLED) return; for (ValueArgument argument : arguments) { diff --git a/compiler/testData/diagnostics/tests/resolve/invoke/kt4204-completeNestedCallsForInvoke.kt b/compiler/testData/diagnostics/tests/resolve/invoke/kt4204-completeNestedCallsForInvoke.kt new file mode 100644 index 00000000000..5fd22fd97d6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/resolve/invoke/kt4204-completeNestedCallsForInvoke.kt @@ -0,0 +1,24 @@ +//KT-4204 ConstraintSystem erased after resolution completion +package c + +public abstract class TestBug1() { + + public fun m3(position: Int) { + position(m1().second!!) + } + + public fun m4(position: (Int)->Int) { + position(m1().second) + } + + private abstract fun m1(): Pair + + private fun position(p: Int) {} + +} + +//from library +public class Pair ( + public val first: A, + public val second: B +) diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index ddc4f976650..077cf295db1 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -5355,6 +5355,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage doTest("compiler/testData/diagnostics/tests/resolve/invoke/kt3833-invokeInsideNestedClass.kt"); } + @TestMetadata("kt4204-completeNestedCallsForInvoke.kt") + public void testKt4204_completeNestedCallsForInvoke() throws Exception { + doTest("compiler/testData/diagnostics/tests/resolve/invoke/kt4204-completeNestedCallsForInvoke.kt"); + } + } @TestMetadata("compiler/testData/diagnostics/tests/resolve/nestedCalls")