File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -2415,8 +2415,16 @@ checkIndividualConformance(NormalProtocolConformance *conformance) {
24152415 ComplainLoc, diag::unchecked_conformance_not_special, ProtoType);
24162416 }
24172417
2418+ bool allowImpliedConditionalConformance = false ;
2419+ if (Proto->isSpecificProtocol (KnownProtocolKind::Sendable)) {
2420+ if (Context.LangOpts .StrictConcurrencyLevel != StrictConcurrency::Complete)
2421+ allowImpliedConditionalConformance = true ;
2422+ } else if (Proto->isMarkerProtocol ()) {
2423+ allowImpliedConditionalConformance = true ;
2424+ }
2425+
24182426 if (conformance->getSourceKind () == ConformanceEntryKind::Implied &&
2419- !Proto-> isMarkerProtocol () ) {
2427+ !allowImpliedConditionalConformance ) {
24202428 // We've got something like:
24212429 //
24222430 // protocol Foo : Proto {}
Original file line number Diff line number Diff line change 1+ // RUN: %target-typecheck-verify-swift -swift-version 6
2+
3+ protocol P : Sendable { }
4+ protocol Q : Sendable { }
5+
6+ struct One < T> { // expected-note {{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
7+ var t : T // expected-error {{stored property 't' of 'Sendable'-conforming generic struct 'One' has non-sendable type 'T'}}
8+ }
9+
10+ extension One : P where T: P { }
11+ // expected-error@-1 {{conditional conformance of type 'One<T>' to protocol 'P' does not imply conformance to inherited protocol 'Sendable'}}
12+ // expected-note@-2 {{did you mean to explicitly state the conformance like 'extension One: Sendable where ...'}}
13+
14+ struct Both < T> { // expected-note {{consider making generic parameter 'T' conform to the 'Sendable' protocol}}
15+ var t : T // expected-error {{stored property 't' of 'Sendable'-conforming generic struct 'Both' has non-sendable type 'T'}}
16+ }
17+
18+ extension Both : P where T: P { }
19+ // expected-error@-1 {{conditional conformance of type 'Both<T>' to protocol 'P' does not imply conformance to inherited protocol 'Sendable'}}
20+ // expected-note@-2 {{did you mean to explicitly state the conformance like 'extension Both: Sendable where ...'}}
21+
22+ extension Both : Q where T: Q { }
23+
24+ func takesSendable< T: Sendable > ( _: T ) { }
25+
26+ takesSendable ( One < Int > ( t: 3 ) )
27+ takesSendable ( Both < Int > ( t: 3 ) )
You can’t perform that action at this time.
0 commit comments