Skip to content

Commit 8fc0af3

Browse files
committed
Sema: Remove conformance lookup callback parameter from checkGenericArguments()
All callers were just doing module lookups.
1 parent dd75809 commit 8fc0af3

File tree

6 files changed

+13
-22
lines changed

6 files changed

+13
-22
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,11 +2691,10 @@ TypeEraserHasViableInitRequest::evaluate(Evaluator &evaluator,
26912691

26922692
// Use invalid 'SourceLoc's to suppress diagnostics.
26932693
auto result = TypeChecker::checkGenericArguments(
2694-
protocol, SourceLoc(), SourceLoc(), typeEraser,
2694+
dc, SourceLoc(), SourceLoc(), typeEraser,
26952695
genericSignature->getGenericParams(),
26962696
genericSignature->getRequirements(),
2697-
QuerySubstitutionMap{subMap},
2698-
LookUpConformanceInModule(dc->getParentModule()));
2697+
QuerySubstitutionMap{subMap});
26992698

27002699
if (result != RequirementCheckResult::Success) {
27012700
unviable.push_back(
@@ -4388,8 +4387,7 @@ static bool typeCheckDerivativeAttr(ASTContext &Ctx, Decl *D,
43884387
source->getGenericParams(), target->getRequirements(),
43894388
[](SubstitutableType *dependentType) {
43904389
return Type(dependentType);
4391-
},
4392-
lookupConformance) == RequirementCheckResult::Success;
4390+
}) == RequirementCheckResult::Success;
43934391
};
43944392

43954393
auto isValidOriginal = [&](AbstractFunctionDecl *originalCandidate) {
@@ -4832,8 +4830,6 @@ doTransposeStaticAndInstanceSelfTypesMatch(AnyFunctionType *transposeType,
48324830

48334831
void AttributeChecker::visitTransposeAttr(TransposeAttr *attr) {
48344832
auto *transpose = cast<FuncDecl>(D);
4835-
auto lookupConformance =
4836-
LookUpConformanceInModule(D->getDeclContext()->getParentModule());
48374833
auto originalName = attr->getOriginalFunctionName();
48384834
auto *transposeInterfaceType =
48394835
transpose->getInterfaceType()->castTo<AnyFunctionType>();
@@ -4928,8 +4924,7 @@ void AttributeChecker::visitTransposeAttr(TransposeAttr *attr) {
49284924
source->getGenericParams(), target->getRequirements(),
49294925
[](SubstitutableType *dependentType) {
49304926
return Type(dependentType);
4931-
},
4932-
lookupConformance) == RequirementCheckResult::Success;
4927+
}) == RequirementCheckResult::Success;
49334928
};
49344929

49354930
auto isValidOriginal = [&](AbstractFunctionDecl *originalCandidate) {

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,6 @@ RequirementCheckResult TypeChecker::checkGenericArguments(
753753
TypeArrayView<GenericTypeParamType> genericParams,
754754
ArrayRef<Requirement> requirements,
755755
TypeSubstitutionFn substitutions,
756-
LookupConformanceFn conformances,
757756
GenericRequirementsCheckListener *listener,
758757
SubstOptions options) {
759758
bool valid = true;
@@ -766,14 +765,18 @@ RequirementCheckResult TypeChecker::checkGenericArguments(
766765
SmallVector<RequirementSet, 8> pendingReqs;
767766
pendingReqs.push_back({requirements, {}});
768767

769-
ASTContext &ctx = dc->getASTContext();
768+
auto *module = dc->getParentModule();
769+
ASTContext &ctx = module->getASTContext();
770770
while (!pendingReqs.empty()) {
771771
auto current = pendingReqs.pop_back_val();
772772

773773
for (const auto &rawReq : current.Requirements) {
774774
auto req = rawReq;
775775
if (current.Parents.empty()) {
776-
auto substed = rawReq.subst(substitutions, conformances, options);
776+
auto substed = rawReq.subst(
777+
substitutions,
778+
LookUpConformanceInModule(module),
779+
options);
777780
if (!substed) {
778781
// Another requirement will fail later; just continue.
779782
valid = false;

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,6 @@ void ConformanceChecker::ensureRequirementsAreSatisfied() {
39563956
{ proto->getSelfInterfaceType() },
39573957
proto->getRequirementSignature(),
39583958
QuerySubstitutionMap{substitutions},
3959-
LookUpConformanceInModule(DC->getParentModule()),
39603959
&listener);
39613960

39623961
switch (result) {
@@ -4434,8 +4433,7 @@ TypeChecker::conformsToProtocol(Type T, ProtocolDecl *Proto, DeclContext *DC,
44344433
auto conditionalCheckResult = checkGenericArguments(
44354434
DC, ComplainLoc, noteLoc, T,
44364435
{lookupResult.getRequirement()->getSelfInterfaceType()}, *condReqs,
4437-
[](SubstitutableType *dependentType) { return Type(dependentType); },
4438-
LookUpConformanceInModule(M));
4436+
[](SubstitutableType *dependentType) { return Type(dependentType); });
44394437
switch (conditionalCheckResult) {
44404438
case RequirementCheckResult::Success:
44414439
break;

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,7 +1097,6 @@ bool AssociatedTypeInference::checkCurrentTypeWitnesses(
10971097
{ proto->getSelfInterfaceType() },
10981098
sanitizedRequirements,
10991099
QuerySubstitutionMap{substitutions},
1100-
LookUpConformanceInModule(dc->getParentModule()),
11011100
nullptr, options);
11021101
switch (result) {
11031102
case RequirementCheckResult::Failure:
@@ -1145,7 +1144,6 @@ bool AssociatedTypeInference::checkConstrainedExtension(ExtensionDecl *ext) {
11451144
ext->getGenericSignature()->getGenericParams(),
11461145
ext->getGenericSignature()->getRequirements(),
11471146
QueryTypeSubstitutionMap{subs},
1148-
LookUpConformanceInModule(ext->getModuleContext()),
11491147
nullptr, options)) {
11501148
case RequirementCheckResult::Success:
11511149
case RequirementCheckResult::SubstitutionFailure:

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -674,8 +674,7 @@ static Type checkContextualRequirements(Type type,
674674
dc, loc, noteLoc, type,
675675
genericSig->getGenericParams(),
676676
genericSig->getRequirements(),
677-
QueryTypeSubstitutionMap{subMap},
678-
LookUpConformanceInModule(dc->getParentModule()));
677+
QueryTypeSubstitutionMap{subMap});
679678

680679
switch (result) {
681680
case RequirementCheckResult::Failure:
@@ -914,8 +913,7 @@ Type TypeChecker::applyUnboundGenericArguments(
914913
checkGenericArguments(dc, loc, noteLoc, unboundType,
915914
genericSig->getGenericParams(),
916915
genericSig->getRequirements(),
917-
QueryTypeSubstitutionMap{subs},
918-
LookUpConformanceInModule(module));
916+
QueryTypeSubstitutionMap{subs});
919917

920918
switch (result) {
921919
case RequirementCheckResult::Failure:

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ RequirementCheckResult checkGenericArguments(
687687
DeclContext *dc, SourceLoc loc, SourceLoc noteLoc, Type owner,
688688
TypeArrayView<GenericTypeParamType> genericParams,
689689
ArrayRef<Requirement> requirements, TypeSubstitutionFn substitutions,
690-
LookupConformanceFn conformances,
691690
GenericRequirementsCheckListener *listener = nullptr,
692691
SubstOptions options = None);
693692

0 commit comments

Comments
 (0)