NI: Fix exception during callable references overload resolution

^KT-35847 Fixed
This commit is contained in:
Denis Zharkov
2020-01-15 16:10:11 +03:00
parent 588259a034
commit 676c99b933
13 changed files with 105 additions and 5 deletions
@@ -55,7 +55,10 @@ class CallableReferenceOverloadConflictResolver(
) {
companion object {
private fun createFlatSignature(candidate: CallableReferenceCandidate) =
FlatSignature.createFromReflectionType(candidate, candidate.candidate, candidate.numDefaults, candidate.reflectionCandidateType)
FlatSignature.createFromReflectionType(
candidate, candidate.candidate, candidate.numDefaults, hasBoundExtensionReceiver = candidate.extensionReceiver != null,
candidate.reflectionCandidateType
)
}
}
@@ -59,6 +59,8 @@ class FlatSignature<out T> constructor(
origin: T,
descriptor: CallableDescriptor,
numDefaults: Int,
// Reflection type for callable references with bound receiver doesn't contain receiver type
hasBoundExtensionReceiver: Boolean,
reflectionType: UnwrappedType
): FlatSignature<T> {
// Note that receiver is taking over descriptor, not reflection type
@@ -66,7 +68,9 @@ class FlatSignature<out T> constructor(
// Plus, currently, receiver for reflection type is taking from *candidate*, see buildReflectionType, this candidate can
// have transient receiver which is not the same in its signature
val receiver = descriptor.extensionReceiverParameter?.type
val parameters = reflectionType.getValueParameterTypesFromCallableReflectionType(receiver == null).map { it.type }
val parameters = reflectionType.getValueParameterTypesFromCallableReflectionType(
receiver != null && !hasBoundExtensionReceiver
).map { it.type }
return FlatSignature(
origin,