Skip to content

Commit

Permalink
Merge pull request swiftlang#59702 from DougGregor/assocated-type-sen…
Browse files Browse the repository at this point in the history
…dable
  • Loading branch information
DougGregor authored Jun 26, 2022
2 parents 0dae896 + 3f38d66 commit 0daa558
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/Sema/TypeCheckProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4588,7 +4588,10 @@ swift::checkTypeWitness(Type type, AssociatedTypeDecl *assocType,

// Check protocol conformances.
for (const auto reqProto : sig->getRequiredProtocols(depTy)) {
if (module->lookupConformance(contextType, reqProto)
if (module->lookupConformance(
contextType, reqProto,
/*allowMissing=*/reqProto->isSpecificProtocol(
KnownProtocolKind::Sendable))
.isInvalid())
return CheckTypeWitnessResult(reqProto->getDeclaredInterfaceType());

Expand Down
18 changes: 18 additions & 0 deletions test/Concurrency/sendable_associated_type.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %target-typecheck-verify-swift -strict-concurrency=complete
// REQUIRES: concurrency

class C1 { } // expected-note{{class 'C1' does not conform to the 'Sendable' protocol}}
@_nonSendable class C2 { } // expected-note{{conformance of 'C2' to 'Sendable' has been explicitly marked unavailable here}}

protocol TestProtocol {
associatedtype Value: Sendable
}

struct Test1: TestProtocol { // expected-warning{{type 'Test1.Value' (aka 'C1') does not conform to the 'Sendable' protocol}}
typealias Value = C1
}

struct Test2: TestProtocol { // expected-warning{{conformance of 'C2' to 'Sendable' is unavailable}}
// expected-note@-1{{in associated type 'Self.Value' (inferred as 'C2')}}
typealias Value = C2
}

0 comments on commit 0daa558

Please sign in to comment.