Skip to content

Commit dd0e366

Browse files
authored
Merge pull request #42270 from DougGregor/missing-sendable-requirement-machine
2 parents 64e9d0b + f3fd64a commit dd0e366

File tree

4 files changed

+35
-5
lines changed

4 files changed

+35
-5
lines changed

lib/AST/RequirementMachine/ConcreteContraction.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ Optional<Type> ConcreteContraction::substTypeParameter(
223223

224224
auto conformance = ((*substBaseType)->isTypeParameter()
225225
? ProtocolConformanceRef(proto)
226-
: module->lookupConformance(*substBaseType, proto));
226+
: module->lookupConformance(*substBaseType, proto,
227+
/*allowMissing=*/true));
227228

228229
// The base type doesn't conform, in which case the requirement remains
229230
// unsubstituted.
@@ -363,7 +364,8 @@ ConcreteContraction::substRequirement(const Requirement &req) const {
363364
auto *proto = req.getProtocolDecl();
364365
auto *module = proto->getParentModule();
365366
if (!substFirstType->isTypeParameter() &&
366-
!module->lookupConformance(substFirstType, proto)) {
367+
!module->lookupConformance(substFirstType, proto,
368+
/*allowMissing=*/true)) {
367369
// Handle the case of <T where T : P, T : C> where C is a class and
368370
// C does not conform to P by leaving the conformance requirement
369371
// unsubstituted.
@@ -664,4 +666,4 @@ bool swift::rewriting::performConcreteContraction(
664666
ConcreteContraction concreteContraction(debug);
665667
return concreteContraction.performConcreteContraction(
666668
requirements, result, errors);
667-
}
669+
}

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,29 @@ extension SendableExtSub: @unchecked Sendable {}
165165
// Still want to know about same-class redundancy
166166
class MultiConformance: @unchecked Sendable {} // expected-note {{'MultiConformance' declares conformance to protocol 'Sendable' here}}
167167
extension MultiConformance: @unchecked Sendable {} // expected-error {{redundant conformance of 'MultiConformance' to protocol 'Sendable'}}
168+
169+
// rdar://91174106 - allow missing Sendable conformances when extending a
170+
// type generically.
171+
// FIXME: Should warn because of missing Sendable, but currently is silent
172+
// because we aren't checking conformance availability here yet.
173+
struct X<T: Sendable> { }
174+
enum Y {}
175+
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)