Skip to content

Commit ba5dec3

Browse files
committed
Revert "[ConformanceLookup] Don't allow skipping inherited unavailable conformances"
This reverts commit 5ecfee7.
1 parent 5e3cf7d commit ba5dec3

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
@@ -258,6 +258,14 @@ void ConformanceLookupTable::inheritConformances(ClassDecl *classDecl,
258258
auto addInheritedConformance = [&](ConformanceEntry *entry) {
259259
auto protocol = entry->getProtocol();
260260

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

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

test/Concurrency/sendable_checking.swift

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

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

110107
struct WrapClass<T: NSClass> {
111108
var t: T
@@ -119,7 +116,7 @@ class SendableSubclass: NSClass, @unchecked Sendable { }
119116

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

125122

0 commit comments

Comments
 (0)