Skip to content

Commit 199e872

Browse files
committed
Revert "[ConformanceLookup] Don't allow skipping inherited unavailable conformances"
This reverts commit 7356fe8.
1 parent 69477c1 commit 199e872

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

lib/AST/ConformanceLookupTable.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,14 @@ void ConformanceLookupTable::inheritConformances(ClassDecl *classDecl,
260260
auto addInheritedConformance = [&](ConformanceEntry *entry) {
261261
auto protocol = entry->getProtocol();
262262

263+
// Don't add unavailable conformances.
264+
if (auto dc = entry->Source.getDeclContext()) {
265+
if (auto ext = dyn_cast<ExtensionDecl>(dc)) {
266+
if (AvailableAttr::isUnavailable(ext))
267+
return;
268+
}
269+
}
270+
263271
// Don't add redundant conformances here. This is merely an
264272
// optimization; resolveConformances() would zap the duplicates
265273
// anyway.
@@ -621,14 +629,6 @@ ConformanceLookupTable::Ordering ConformanceLookupTable::compareConformances(
621629

622630
// Allow replacement of an explicit conformance to a marker protocol.
623631
// (This permits redundant explicit declarations of `Sendable`.)
624-
//
625-
// FIXME: We need to warn on attempts to make an unavailable Sendable
626-
// conformance available, which does not work.
627-
//
628-
// We probably also want to warn if there is an existing, explicit
629-
// conformance, so clients are prompted to remove retroactive unchecked
630-
// Sendable conformances when the proper Sendable conformance is added
631-
// in the original module.
632632
return (kind == ConformanceEntryKind::Explicit
633633
&& entry->getProtocol()->isMarkerProtocol());
634634
};
@@ -880,6 +880,8 @@ DeclContext *ConformanceLookupTable::getConformingContext(
880880
return nullptr;
881881
auto inheritedConformance = swift::lookupConformance(
882882
superclassTy, protocol, /*allowMissing=*/false);
883+
if (inheritedConformance.hasUnavailableConformance())
884+
inheritedConformance = ProtocolConformanceRef::forInvalid();
883885
if (inheritedConformance)
884886
return superclassDecl;
885887
} while ((superclassDecl = superclassDecl->getSuperclassDecl()));

test/Concurrency/sendable_checking.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ public actor MyActor: MyProto {
101101
}
102102

103103
// Make sure the generic signature doesn't minimize away Sendable requirements.
104-
class NSClass { }
105-
106-
@available(*, unavailable)
107-
extension NSClass: @unchecked Sendable {} // expected-note {{conformance of 'NSClass' to 'Sendable' has been explicitly marked unavailable here}}
104+
@_nonSendable class NSClass { }
108105

109106
struct WrapClass<T: NSClass> {
110107
var t: T
@@ -118,7 +115,7 @@ class SendableSubclass: NSClass, @unchecked Sendable { }
118115

119116
@available(SwiftStdlib 5.1, *)
120117
func testSubclassing(obj: SendableSubclass) async {
121-
acceptCV(obj) // expected-warning {{conformance of 'NSClass' to 'Sendable' is unavailable; this is an error in the Swift 6 language mode}}
118+
acceptCV(obj) // okay!
122119
}
123120

124121

0 commit comments

Comments
 (0)