@@ -8348,8 +8348,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
8348
8348
}
8349
8349
8350
8350
// Check whether this type conforms to the protocol.
8351
- auto conformance = DC->getParentModule()->lookupConformance(
8352
- type, protocol, /*allowMissing=*/true);
8351
+ auto conformance = lookupConformance(type, protocol);
8353
8352
if (conformance) {
8354
8353
return recordConformance(conformance);
8355
8354
}
@@ -8469,8 +8468,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
8469
8468
8470
8469
if (auto rawValue = isRawRepresentable(*this, type)) {
8471
8470
if (!rawValue->isTypeVariableOrMember() &&
8472
- TypeChecker::conformsToProtocol(rawValue, protocol,
8473
- DC->getParentModule())) {
8471
+ lookupConformance(rawValue, protocol)) {
8474
8472
auto *fix = UseRawValue::create(*this, type, protocolTy, loc);
8475
8473
// Since this is a conformance requirement failure (where the
8476
8474
// source is most likely an argument), let's increase its impact
@@ -8629,11 +8627,9 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyTransitivelyConformsTo(
8629
8627
8630
8628
auto *protocol = protocolTy->castTo<ProtocolType>()->getDecl();
8631
8629
8632
- auto *M = DC->getParentModule();
8633
-
8634
8630
// First, let's check whether the type itself conforms,
8635
8631
// if it does - we are done.
8636
- if (M-> lookupConformance(resolvedTy, protocol))
8632
+ if (lookupConformance(resolvedTy, protocol))
8637
8633
return SolutionKind::Solved;
8638
8634
8639
8635
// If the type doesn't conform, let's check whether
@@ -8705,10 +8701,9 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyTransitivelyConformsTo(
8705
8701
}
8706
8702
}
8707
8703
8708
- return llvm::any_of(typesToCheck,
8709
- [&](Type type) {
8710
- return bool(M->lookupConformance(type, protocol));
8711
- })
8704
+ return llvm::any_of(
8705
+ typesToCheck,
8706
+ [&](Type type) { return bool(lookupConformance(type, protocol)); })
8712
8707
? SolutionKind::Solved
8713
8708
: SolutionKind::Error;
8714
8709
}
@@ -9295,7 +9290,7 @@ static bool mayBeForKeyPathSubscriptWithoutLabel(ConstraintSystem &cs,
9295
9290
/// This is useful to figure out whether it makes sense to
9296
9291
/// perform dynamic member lookup or not.
9297
9292
static bool
9298
- allFromConditionalConformances(DeclContext *DC , Type baseTy,
9293
+ allFromConditionalConformances(ConstraintSystem &cs , Type baseTy,
9299
9294
ArrayRef<OverloadChoice> candidates) {
9300
9295
auto *NTD = baseTy->getAnyNominal();
9301
9296
if (!NTD)
@@ -9314,8 +9309,7 @@ allFromConditionalConformances(DeclContext *DC, Type baseTy,
9314
9309
}
9315
9310
9316
9311
if (auto *protocol = candidateDC->getSelfProtocolDecl()) {
9317
- auto conformance = DC->getParentModule()->lookupConformance(
9318
- baseTy, protocol);
9312
+ auto conformance = cs.lookupConformance(baseTy, protocol);
9319
9313
if (!conformance.isConcrete())
9320
9314
return false;
9321
9315
@@ -10053,7 +10047,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
10053
10047
const auto &candidates = result.ViableCandidates;
10054
10048
10055
10049
if ((candidates.empty() ||
10056
- allFromConditionalConformances(DC , instanceTy, candidates)) &&
10050
+ allFromConditionalConformances(*this , instanceTy, candidates)) &&
10057
10051
!isSelfRecursiveKeyPathDynamicMemberLookup(*this, baseTy,
10058
10052
memberLocator)) {
10059
10053
auto &ctx = getASTContext();
@@ -10636,7 +10630,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
10636
10630
// called within extensions to that type (usually adding 'clamp').
10637
10631
bool treatAsViable =
10638
10632
(member.isSimpleName("min") || member.isSimpleName("max")) &&
10639
- allFromConditionalConformances(DC, baseTy, result.ViableCandidates);
10633
+ allFromConditionalConformances(*this, baseTy,
10634
+ result.ViableCandidates);
10640
10635
10641
10636
generateConstraints(
10642
10637
candidates, memberTy, outerAlternatives, useDC, locator, llvm::None,
@@ -11044,8 +11039,7 @@ ConstraintSystem::simplifyValueWitnessConstraint(
11044
11039
// conformance already?
11045
11040
auto proto = requirement->getDeclContext()->getSelfProtocolDecl();
11046
11041
assert(proto && "Value witness constraint for a non-requirement");
11047
- auto conformance = useDC->getParentModule()->lookupConformance(
11048
- baseObjectType, proto);
11042
+ auto conformance = lookupConformance(baseObjectType, proto);
11049
11043
if (!conformance)
11050
11044
return fail();
11051
11045
0 commit comments