NI: Fix callable references resolution when LHS is generic nested class

In case of null qualifier, we should not look into any static scope
NB: factory::createCallableProcessor returns NoExplicitReceiver processor
in case of null-receiver, that makes resolving the call in the test as
`property(::key)` that matches to the property itself, thus leading to
overload resolution ambiguity

^KT-35887 Fixed
This commit is contained in:
Denis Zharkov
2020-01-14 18:50:17 +03:00
parent 4ff8acf5d7
commit c48539feb3
8 changed files with 80 additions and 2 deletions
@@ -85,11 +85,15 @@ fun createCallableReferenceProcessor(factory: CallableReferencesCandidateFactory
return factory.createCallableProcessor(explicitReceiver)
}
is LHSResult.Type -> {
val static = factory.createCallableProcessor(lhsResult.qualifier)
val static = lhsResult.qualifier?.let(factory::createCallableProcessor)
val unbound = factory.createCallableProcessor(lhsResult.unboundDetailedReceiver)
// note that if we use PrioritizedCompositeScopeTowerProcessor then static will win over unbound members
val staticOrUnbound = SamePriorityCompositeScopeTowerProcessor(static, unbound)
val staticOrUnbound =
if (static != null)
SamePriorityCompositeScopeTowerProcessor(static, unbound)
else
unbound
val asValue = lhsResult.qualifier?.classValueReceiverWithSmartCastInfo ?: return staticOrUnbound
return PrioritizedCompositeScopeTowerProcessor(staticOrUnbound, factory.createCallableProcessor(asValue))