diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index 8700ae73848..2bf545e83c4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -313,28 +313,6 @@ public class CandidateResolver( return ValueArgumentsCheckingResult(resultStatus, checkingResult.argumentTypes) } - private fun checkReceivers(context: CallCandidateResolutionContext): ResolutionStatus { - var resultStatus = SUCCESS - val candidateCall = context.candidateCall - - // Comment about a very special case. - // Call 'b.foo(1)' where class 'Foo' has an extension member 'fun B.invoke(Int)' should be checked two times for safe call (in 'checkReceiver'), because - // both 'b' (receiver) and 'foo' (this object) might be nullable. In the first case we mark dot, in the second 'foo'. - // Class 'CallForImplicitInvoke' helps up to recognise this case, and parameter 'implicitInvokeCheck' helps us to distinguish whether we check receiver or this object. - - resultStatus = resultStatus.combine(context.checkReceiver( - candidateCall, - candidateCall.getResultingDescriptor().getExtensionReceiverParameter(), - candidateCall.getExtensionReceiver(), candidateCall.getExplicitReceiverKind().isExtensionReceiver(), false)) - - resultStatus = resultStatus.combine(context.checkReceiver(candidateCall, - candidateCall.getResultingDescriptor().getDispatchReceiverParameter(), candidateCall.getDispatchReceiver(), - candidateCall.getExplicitReceiverKind().isDispatchReceiver(), - // for the invocation 'foo(1)' where foo is a variable of function type we should mark 'foo' if there is unsafe call error - context.call is CallForImplicitInvoke)) - return resultStatus - } - private fun > checkValueArgumentTypes( context: CallResolutionContext, candidateCall: MutableResolvedCall, @@ -427,6 +405,28 @@ public class CandidateResolver( } } + private fun checkReceivers(context: CallCandidateResolutionContext): ResolutionStatus { + var resultStatus = SUCCESS + val candidateCall = context.candidateCall + + // Comment about a very special case. + // Call 'b.foo(1)' where class 'Foo' has an extension member 'fun B.invoke(Int)' should be checked two times for safe call (in 'checkReceiver'), because + // both 'b' (receiver) and 'foo' (this object) might be nullable. In the first case we mark dot, in the second 'foo'. + // Class 'CallForImplicitInvoke' helps up to recognise this case, and parameter 'implicitInvokeCheck' helps us to distinguish whether we check receiver or this object. + + resultStatus = resultStatus.combine(context.checkReceiver( + candidateCall, + candidateCall.getResultingDescriptor().getExtensionReceiverParameter(), + candidateCall.getExtensionReceiver(), candidateCall.getExplicitReceiverKind().isExtensionReceiver(), false)) + + resultStatus = resultStatus.combine(context.checkReceiver(candidateCall, + candidateCall.getResultingDescriptor().getDispatchReceiverParameter(), candidateCall.getDispatchReceiver(), + candidateCall.getExplicitReceiverKind().isDispatchReceiver(), + // for the invocation 'foo(1)' where foo is a variable of function type we should mark 'foo' if there is unsafe call error + context.call is CallForImplicitInvoke)) + return resultStatus + } + private fun CallCandidateResolutionContext.checkReceiver( candidateCall: ResolvedCall, receiverParameter: ReceiverParameterDescriptor?,