Skip to content

Commit ad06e7d

Browse files
authored
Merge pull request #59703 from DougGregor/associated-type-sendable-5.7
2 parents 3445d04 + 7c259da commit ad06e7d

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4567,7 +4567,10 @@ swift::checkTypeWitness(Type type, AssociatedTypeDecl *assocType,
45674567

45684568
// Check protocol conformances.
45694569
for (const auto reqProto : sig->getRequiredProtocols(depTy)) {
4570-
if (module->lookupConformance(contextType, reqProto)
4570+
if (module->lookupConformance(
4571+
contextType, reqProto,
4572+
/*allowMissing=*/reqProto->isSpecificProtocol(
4573+
KnownProtocolKind::Sendable))
45714574
.isInvalid())
45724575
return CheckTypeWitnessResult(reqProto->getDeclaredInterfaceType());
45734576

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %target-typecheck-verify-swift -strict-concurrency=complete
2+
// REQUIRES: concurrency
3+
4+
class C1 { } // expected-note{{class 'C1' does not conform to the 'Sendable' protocol}}
5+
@_nonSendable class C2 { } // expected-note{{conformance of 'C2' to 'Sendable' has been explicitly marked unavailable here}}
6+
7+
protocol TestProtocol {
8+
associatedtype Value: Sendable
9+
}
10+
11+
struct Test1: TestProtocol { // expected-warning{{type 'Test1.Value' (aka 'C1') does not conform to the 'Sendable' protocol}}
12+
typealias Value = C1
13+
}
14+
15+
struct Test2: TestProtocol { // expected-warning{{conformance of 'C2' to 'Sendable' is unavailable}}
16+
// expected-note@-1{{in associated type 'Self.Value' (inferred as 'C2')}}
17+
typealias Value = C2
18+
}

0 commit comments

Comments
 (0)