Skip to content

Commit f3fd64a

Browse files
committed
Support missing Sendable conformances everywhere in the requirement machine
1 parent 45c7d6f commit f3fd64a

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

lib/AST/RequirementMachine/ConcreteTypeWitness.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,8 @@ void PropertyMap::concretizeNestedTypesFromConcreteParent(
144144
auto *module = proto->getParentModule();
145145

146146
auto conformance = module->lookupConformance(concreteType,
147-
const_cast<ProtocolDecl *>(proto));
147+
const_cast<ProtocolDecl *>(proto),
148+
/*allowMissing=*/true);
148149
if (conformance.isInvalid()) {
149150
// For superclass rules, it is totally fine to have a signature like:
150151
//

lib/AST/RequirementMachine/RequirementLowering.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,8 @@ static void desugarConformanceRequirement(Type subjectType, Type constraintType,
292292
// Check if the subject type actually conforms.
293293
auto *protoDecl = constraintType->castTo<ProtocolType>()->getDecl();
294294
auto *module = protoDecl->getParentModule();
295-
auto conformance = module->lookupConformance(subjectType, protoDecl);
295+
auto conformance = module->lookupConformance(
296+
subjectType, protoDecl, /*allowMissing=*/true);
296297
if (conformance.isInvalid()) {
297298
errors.push_back(RequirementError::forInvalidRequirementSubject(
298299
{RequirementKind::Conformance, subjectType, constraintType}, loc));

test/Concurrency/sendable_conformance_checking.swift

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,26 @@ extension MultiConformance: @unchecked Sendable {} // expected-error {{redundant
168168

169169
// rdar://91174106 - allow missing Sendable conformances when extending a
170170
// type generically.
171-
// FIXME: Should warn because of missing Sendable, but currently is silent.
172-
// We don't want a hard error except in Swift 6.
171+
// FIXME: Should warn because of missing Sendable, but currently is silent
172+
// because we aren't checking conformance availability here yet.
173173
struct X<T: Sendable> { }
174174
enum Y {}
175175
extension X where T == Y {}
176+
177+
protocol P2 {
178+
associatedtype A: Sendable
179+
}
180+
181+
enum Y2: P2, P3 {
182+
typealias A = Y
183+
}
184+
185+
struct X2<T: P2> { }
186+
extension X2 where T == Y2 { }
187+
188+
protocol P3 {
189+
associatedtype A
190+
}
191+
192+
struct X3<T: P3> where T.A: Sendable { }
193+
extension X3 where T == Y2 { }

0 commit comments

Comments
 (0)