mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
AST: Use availability to disambiguate multiple overlapping conformances
If a conformance is found in an imported module as well as the current module, and one of the two conformances is conditionally unavailable on the current deployment target, pick the one that is always available. Fixes <rdar://problem/78633800>.
This commit is contained in:
@@ -529,6 +529,18 @@ ConformanceLookupTable::Ordering ConformanceLookupTable::compareConformances(
|
||||
ConformanceEntry *lhs,
|
||||
ConformanceEntry *rhs,
|
||||
bool &diagnoseSuperseded) {
|
||||
// If only one of the conformances is unconditionally available on the
|
||||
// current deployment target, pick that one.
|
||||
//
|
||||
// FIXME: Conformance lookup should really depend on source location for
|
||||
// this to be 100% correct.
|
||||
if (lhs->getDeclContext()->isAlwaysAvailableConformanceContext() !=
|
||||
rhs->getDeclContext()->isAlwaysAvailableConformanceContext()) {
|
||||
return (lhs->getDeclContext()->isAlwaysAvailableConformanceContext()
|
||||
? Ordering::Before
|
||||
: Ordering::After);
|
||||
}
|
||||
|
||||
// If one entry is fixed and the other is not, we have our answer.
|
||||
if (lhs->isFixed() != rhs->isFixed()) {
|
||||
// If the non-fixed conformance is not replaceable, we have a failure to
|
||||
|
||||
Reference in New Issue
Block a user