Fix ambiguity on callable reference for expect members
Expect members should always lose in resolution to non-expect members, be it simple calls or callable references. Note that there should be exactly one actual member for each expect member in correct code, so both ways to check for expect vs non-expect are correct: either before signature comparison, or after. #KT-20903 Fixed
This commit is contained in:
+10
-1
@@ -352,7 +352,16 @@ open class OverloadingConflictResolver<C : Any>(
|
||||
|
||||
val fSignature = FlatSignature.createFromCallableDescriptor(f)
|
||||
val gSignature = FlatSignature.createFromCallableDescriptor(g)
|
||||
return createEmptyConstraintSystem().isSignatureNotLessSpecific(fSignature, gSignature, SpecificityComparisonWithNumerics, specificityComparator)
|
||||
if (!createEmptyConstraintSystem().isSignatureNotLessSpecific(fSignature, gSignature, SpecificityComparisonWithNumerics, specificityComparator)) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (f is CallableMemberDescriptor && g is CallableMemberDescriptor) {
|
||||
if (!f.isExpect && g.isExpect) return true
|
||||
if (f.isExpect && !g.isExpect) return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
private fun isNotLessSpecificCallableReference(f: CallableDescriptor, g: CallableDescriptor): Boolean =
|
||||
|
||||
Reference in New Issue
Block a user