[NI] Make callable references more robust to overloads of outer call

#KT-30676 Fixed
This commit is contained in:
Mikhail Zarechenskiy
2019-04-04 12:03:15 +03:00
parent 20a7f387bf
commit c3bc6ef2fa
17 changed files with 147 additions and 17 deletions
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.createLookupLocation
import org.jetbrains.kotlin.resolve.calls.callUtil.getCall
import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
import org.jetbrains.kotlin.resolve.calls.callUtil.isSafeCall
import org.jetbrains.kotlin.resolve.calls.components.CallableReferenceResolver
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzer
import org.jetbrains.kotlin.resolve.calls.context.BasicCallResolutionContext
@@ -67,7 +68,8 @@ class PSICallResolver(
private val postponedArgumentsAnalyzer: PostponedArgumentsAnalyzer,
private val kotlinConstraintSystemCompleter: KotlinConstraintSystemCompleter,
private val deprecationResolver: DeprecationResolver,
private val moduleDescriptor: ModuleDescriptor
private val moduleDescriptor: ModuleDescriptor,
private val callableReferenceResolver: CallableReferenceResolver
) {
private val givenCandidatesName = Name.special("<given candidates>")
@@ -389,7 +391,9 @@ class PSICallResolver(
override fun factoryForVariable(stripExplicitReceiver: Boolean): CandidateFactory<KotlinResolutionCandidate> {
val explicitReceiver = if (stripExplicitReceiver) null else kotlinCall.explicitReceiver
val variableCall = PSIKotlinCallForVariable(kotlinCall, explicitReceiver, kotlinCall.name)
return SimpleCandidateFactory(callComponents, scopeTower, variableCall, createResolutionCallbacks(context))
return SimpleCandidateFactory(
callComponents, scopeTower, variableCall, createResolutionCallbacks(context), callableReferenceResolver
)
}
override fun factoryForInvoke(variable: KotlinResolutionCandidate, useExplicitReceiver: Boolean):
@@ -410,7 +414,7 @@ class PSICallResolver(
}
return variableCallArgument.receiver to SimpleCandidateFactory(
callComponents, scopeTower, callForInvoke, createResolutionCallbacks(context)
callComponents, scopeTower, callForInvoke, createResolutionCallbacks(context), callableReferenceResolver
)
}