@@ -8425,8 +8425,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
8425
8425
}
8426
8426
8427
8427
// Check whether this type conforms to the protocol.
8428
- auto conformance = DC->getParentModule()->lookupConformance(
8429
- type, protocol, /*allowMissing=*/true);
8428
+ auto conformance = lookupConformance(type, protocol);
8430
8429
if (conformance) {
8431
8430
return recordConformance(conformance);
8432
8431
}
@@ -8546,8 +8545,7 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyConformsToConstraint(
8546
8545
8547
8546
if (auto rawValue = isRawRepresentable(*this, type)) {
8548
8547
if (!rawValue->isTypeVariableOrMember() &&
8549
- TypeChecker::conformsToProtocol(rawValue, protocol,
8550
- DC->getParentModule())) {
8548
+ lookupConformance(rawValue, protocol)) {
8551
8549
auto *fix = UseRawValue::create(*this, type, protocolTy, loc);
8552
8550
// Since this is a conformance requirement failure (where the
8553
8551
// source is most likely an argument), let's increase its impact
@@ -8706,11 +8704,9 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyTransitivelyConformsTo(
8706
8704
8707
8705
auto *protocol = protocolTy->castTo<ProtocolType>()->getDecl();
8708
8706
8709
- auto *M = DC->getParentModule();
8710
-
8711
8707
// First, let's check whether the type itself conforms,
8712
8708
// if it does - we are done.
8713
- if (M-> lookupConformance(resolvedTy, protocol))
8709
+ if (lookupConformance(resolvedTy, protocol))
8714
8710
return SolutionKind::Solved;
8715
8711
8716
8712
// If the type doesn't conform, let's check whether
@@ -8782,10 +8778,9 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyTransitivelyConformsTo(
8782
8778
}
8783
8779
}
8784
8780
8785
- return llvm::any_of(typesToCheck,
8786
- [&](Type type) {
8787
- return bool(M->lookupConformance(type, protocol));
8788
- })
8781
+ return llvm::any_of(
8782
+ typesToCheck,
8783
+ [&](Type type) { return bool(lookupConformance(type, protocol)); })
8789
8784
? SolutionKind::Solved
8790
8785
: SolutionKind::Error;
8791
8786
}
@@ -9372,7 +9367,7 @@ static bool mayBeForKeyPathSubscriptWithoutLabel(ConstraintSystem &cs,
9372
9367
/// This is useful to figure out whether it makes sense to
9373
9368
/// perform dynamic member lookup or not.
9374
9369
static bool
9375
- allFromConditionalConformances(DeclContext *DC , Type baseTy,
9370
+ allFromConditionalConformances(ConstraintSystem &cs , Type baseTy,
9376
9371
ArrayRef<OverloadChoice> candidates) {
9377
9372
auto *NTD = baseTy->getAnyNominal();
9378
9373
if (!NTD)
@@ -9391,8 +9386,7 @@ allFromConditionalConformances(DeclContext *DC, Type baseTy,
9391
9386
}
9392
9387
9393
9388
if (auto *protocol = candidateDC->getSelfProtocolDecl()) {
9394
- auto conformance = DC->getParentModule()->lookupConformance(
9395
- baseTy, protocol);
9389
+ auto conformance = cs.lookupConformance(baseTy, protocol);
9396
9390
if (!conformance.isConcrete())
9397
9391
return false;
9398
9392
@@ -10130,7 +10124,7 @@ performMemberLookup(ConstraintKind constraintKind, DeclNameRef memberName,
10130
10124
const auto &candidates = result.ViableCandidates;
10131
10125
10132
10126
if ((candidates.empty() ||
10133
- allFromConditionalConformances(DC , instanceTy, candidates)) &&
10127
+ allFromConditionalConformances(*this , instanceTy, candidates)) &&
10134
10128
!isSelfRecursiveKeyPathDynamicMemberLookup(*this, baseTy,
10135
10129
memberLocator)) {
10136
10130
auto &ctx = getASTContext();
@@ -10713,7 +10707,8 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
10713
10707
// called within extensions to that type (usually adding 'clamp').
10714
10708
bool treatAsViable =
10715
10709
(member.isSimpleName("min") || member.isSimpleName("max")) &&
10716
- allFromConditionalConformances(DC, baseTy, result.ViableCandidates);
10710
+ allFromConditionalConformances(*this, baseTy,
10711
+ result.ViableCandidates);
10717
10712
10718
10713
generateConstraints(
10719
10714
candidates, memberTy, outerAlternatives, useDC, locator, llvm::None,
@@ -11121,8 +11116,7 @@ ConstraintSystem::simplifyValueWitnessConstraint(
11121
11116
// conformance already?
11122
11117
auto proto = requirement->getDeclContext()->getSelfProtocolDecl();
11123
11118
assert(proto && "Value witness constraint for a non-requirement");
11124
- auto conformance = useDC->getParentModule()->lookupConformance(
11125
- baseObjectType, proto);
11119
+ auto conformance = lookupConformance(baseObjectType, proto);
11126
11120
if (!conformance)
11127
11121
return fail();
11128
11122
0 commit comments