[FE] Provide overloadability for candidates with different CR

This commit is contained in:
Anastasiya Shadrina
2021-09-18 19:00:37 +07:00
committed by TeamCityServer
parent 155e7b211b
commit a091b345a0
12 changed files with 108 additions and 6 deletions
@@ -66,9 +66,11 @@ private fun <T> SimpleConstraintSystem.isValueParameterTypeNotLessSpecific(
): Boolean {
val typeParameters = general.typeParameters
val typeSubstitutor = registerTypeVariables(typeParameters)
val valueParameterTypes = specific.valueParameterTypes.map(typeKindSelector).zip(general.valueParameterTypes.map(typeKindSelector))
val valueParamsWithoutContextReceivers =
specific.valueParameterTypes.drop(specific.contextReceiverCount).map(typeKindSelector)
.zip(general.valueParameterTypes.drop(general.contextReceiverCount).map(typeKindSelector))
for ((specificType, generalType) in valueParameterTypes) {
for ((specificType, generalType) in valueParamsWithoutContextReceivers) {
if (specificType == null || generalType == null) continue
if (specificityComparator.isDefinitelyLessSpecific(specificType, generalType)) {
@@ -108,8 +110,9 @@ fun <T> SimpleConstraintSystem.isSignatureNotLessSpecific(
useOriginalSamTypes: Boolean = false
): Boolean {
if (specific.hasExtensionReceiver != general.hasExtensionReceiver) return false
if (specific.contextReceiverCount != general.contextReceiverCount) return false
if (specific.valueParameterTypes.size != general.valueParameterTypes.size) return false
if (specific.contextReceiverCount > general.contextReceiverCount) return false
if (specific.valueParameterTypes.size - specific.contextReceiverCount != general.valueParameterTypes.size - general.contextReceiverCount)
return false
if (!isValueParameterTypeNotLessSpecific(specific, general, callbacks, specificityComparator) { it?.resultType }) {
return false