Skip to content

Commit 8d05362

Browse files
committed
AST: Simplify some lookupConformance() callers
1 parent 35b78c9 commit 8d05362

File tree

3 files changed

+9
-32
lines changed

3 files changed

+9
-32
lines changed

lib/AST/DistributedDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,7 @@ swift::getDistributedActorAsActorConformanceRef(ASTContext &C) {
130130
auto distributedActorAsActorConformance =
131131
getDistributedActorAsActorConformance(C);
132132

133-
auto actorProto = C.getProtocol(KnownProtocolKind::Actor);
134-
return ProtocolConformanceRef(actorProto, distributedActorAsActorConformance);
133+
return ProtocolConformanceRef(distributedActorAsActorConformance);
135134
}
136135
NormalProtocolConformance *
137136
swift::getDistributedActorAsActorConformance(ASTContext &C) {

lib/AST/SubstitutionMap.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,8 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
271271

272272
// If the protocol is invertible, fall back to a global lookup instead of
273273
// evaluating a conformance path, to avoid an infinite substitution issue.
274-
if (proto->getInvertibleProtocolKind()) {
275-
auto substType = type.subst(*this);
276-
if (!substType->isTypeParameter())
277-
return swift::lookupConformance(substType, proto);
278-
return ProtocolConformanceRef(proto);
279-
}
274+
if (proto->getInvertibleProtocolKind())
275+
return swift::lookupConformance(type.subst(*this), proto);
280276

281277
auto path = genericSig->getConformancePath(type, proto);
282278

@@ -300,18 +296,7 @@ SubstitutionMap::lookupConformance(CanType type, ProtocolDecl *proto) const {
300296
if (conformance.isAbstract()) {
301297
// FIXME: Rip this out once we can get a concrete conformance from
302298
// an archetype.
303-
auto substType = type.subst(*this);
304-
if (substType->hasError())
305-
return ProtocolConformanceRef(proto);
306-
307-
if ((!substType->is<ArchetypeType>() ||
308-
substType->castTo<ArchetypeType>()->getSuperclass()) &&
309-
!substType->isTypeParameter() &&
310-
!substType->isExistentialType()) {
311-
return swift::lookupConformance(substType, proto);
312-
}
313-
314-
return ProtocolConformanceRef(proto);
299+
return swift::lookupConformance(type.subst(*this), proto);
315300
}
316301

317302
// For the second step, we're looking into the requirement signature for
@@ -511,9 +496,6 @@ LookUpConformanceInOverrideSubs::operator()(CanType type,
511496
if (auto conformance = info.BaseSubMap.lookupConformance(type, proto))
512497
return conformance;
513498

514-
if (substType->isTypeParameter())
515-
return ProtocolConformanceRef(proto);
516-
517499
return lookupConformance(substType, proto);
518500
}
519501

lib/AST/Type.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2306,15 +2306,11 @@ class IsBindableVisitor : public TypeVisitor<IsBindableVisitor, CanType, CanType
23062306
QueryTypeSubstitutionMap{newParamsMap},
23072307
LookUpConformanceInModule());
23082308

2309-
if (newSubstTy->isTypeParameter()) {
2310-
newConformances.push_back(ProtocolConformanceRef(proto));
2311-
} else {
2312-
auto newConformance
2313-
= lookupConformance(newSubstTy, proto, /*allowMissing=*/true);
2314-
if (!newConformance)
2315-
return CanType();
2316-
newConformances.push_back(newConformance);
2317-
}
2309+
auto newConformance
2310+
= lookupConformance(newSubstTy, proto, /*allowMissing=*/true);
2311+
if (!newConformance)
2312+
return CanType();
2313+
newConformances.push_back(newConformance);
23182314
}
23192315
}
23202316

0 commit comments

Comments
 (0)