Skip to content

Commit 69b2435

Browse files
committed
[Concurrency] Don't warn about re-stating inherited unavailable conformances
to `Sendable`. The unavailability check was not using the root conformance, which is where the extension declaration with the unavailability attribute is for inherited conformances, leading to bogus warnings about re-stating unchecked conformances to `Sendable`.
1 parent 3349e61 commit 69b2435

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6195,7 +6195,11 @@ bool swift::checkSendableConformance(
61956195
return false;
61966196

61976197
// If this is an always-unavailable conformance, there's nothing to check.
6198-
if (auto ext = dyn_cast<ExtensionDecl>(conformanceDC)) {
6198+
// We always use the root conformance for this check, because inherited
6199+
// conformances need to walk back to the original declaration for the
6200+
// superclass conformance to find an unavailable attribute.
6201+
if (auto ext = dyn_cast<ExtensionDecl>(
6202+
conformance->getRootConformance()->getDeclContext())) {
61996203
if (AvailableAttr::isUnavailable(ext))
62006204
return false;
62016205
}

test/Concurrency/concurrent_value_checking.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,14 @@ final class C7<T>: Sendable { }
380380

381381
class C9: Sendable { } // expected-warning{{non-final class 'C9' cannot conform to 'Sendable'; use '@unchecked Sendable'}}
382382

383+
@available(*, unavailable)
384+
extension HasUnavailableSendable : @unchecked Sendable { }
385+
386+
class HasUnavailableSendable {
387+
}
388+
389+
class NoRestated: HasUnavailableSendable {} // okay
390+
383391
@globalActor
384392
struct SomeActor {
385393
static let shared = A1()

0 commit comments

Comments
 (0)