Skip to content

Commit 0b8bce8

Browse files
committed
Sema: Remove ConformanceCheckOptions parameter from checkGenericArguments()
1 parent 9eb9b8d commit 0b8bce8

File tree

6 files changed

+14
-35
lines changed

6 files changed

+14
-35
lines changed

lib/Sema/TypeCheckAttr.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,8 +2695,7 @@ TypeEraserHasViableInitRequest::evaluate(Evaluator &evaluator,
26952695
genericSignature->getGenericParams(),
26962696
genericSignature->getRequirements(),
26972697
QuerySubstitutionMap{subMap},
2698-
TypeChecker::LookUpConformance(dc),
2699-
None);
2698+
TypeChecker::LookUpConformance(dc));
27002699

27012700
if (result != RequirementCheckResult::Success) {
27022701
unviable.push_back(
@@ -4383,20 +4382,14 @@ static bool typeCheckDerivativeAttr(ASTContext &Ctx, Decl *D,
43834382
if (!source)
43844383
return false;
43854384
// Check if target's requirements are satisfied by source.
4386-
// Cancel diagnostics using `DiagnosticTransaction`.
4387-
// Diagnostics should not be emitted because this function is used to
4388-
// check candidates; if no candidates match, a separate diagnostic will
4389-
// be produced.
4390-
DiagnosticTransaction transaction(Ctx.Diags);
4391-
SWIFT_DEFER { transaction.abort(); };
4385+
// Use invalid 'SourceLoc's to suppress diagnostics.
43924386
return TypeChecker::checkGenericArguments(
4393-
derivative, originalName.Loc.getBaseNameLoc(),
4394-
originalName.Loc.getBaseNameLoc(), Type(),
4387+
derivative, SourceLoc(), SourceLoc(), Type(),
43954388
source->getGenericParams(), target->getRequirements(),
43964389
[](SubstitutableType *dependentType) {
43974390
return Type(dependentType);
43984391
},
4399-
lookupConformance, None) == RequirementCheckResult::Success;
4392+
lookupConformance) == RequirementCheckResult::Success;
44004393
};
44014394

44024395
auto isValidOriginal = [&](AbstractFunctionDecl *originalCandidate) {
@@ -4926,20 +4919,17 @@ void AttributeChecker::visitTransposeAttr(TransposeAttr *attr) {
49264919
if (!source)
49274920
return false;
49284921
// Check if target's requirements are satisfied by source.
4929-
// Cancel diagnostics using `DiagnosticTransaction`.
4922+
// Use invalid 'SourceLoc's to suppress diagnostics.
49304923
// Diagnostics should not be emitted because this function is used to
49314924
// check candidates; if no candidates match, a separate diagnostic will
49324925
// be produced.
4933-
DiagnosticTransaction transaction(Ctx.Diags);
4934-
SWIFT_DEFER { transaction.abort(); };
49354926
return TypeChecker::checkGenericArguments(
4936-
transpose, originalName.Loc.getBaseNameLoc(),
4937-
originalName.Loc.getBaseNameLoc(), Type(),
4927+
transpose, SourceLoc(), SourceLoc(), Type(),
49384928
source->getGenericParams(), target->getRequirements(),
49394929
[](SubstitutableType *dependentType) {
49404930
return Type(dependentType);
49414931
},
4942-
lookupConformance, None) == RequirementCheckResult::Success;
4932+
lookupConformance) == RequirementCheckResult::Success;
49434933
};
49444934

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

lib/Sema/TypeCheckGeneric.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -754,14 +754,10 @@ RequirementCheckResult TypeChecker::checkGenericArguments(
754754
ArrayRef<Requirement> requirements,
755755
TypeSubstitutionFn substitutions,
756756
LookupConformanceFn conformances,
757-
ConformanceCheckOptions conformanceOptions,
758757
GenericRequirementsCheckListener *listener,
759758
SubstOptions options) {
760759
bool valid = true;
761760

762-
// We handle any conditional requirements ourselves.
763-
conformanceOptions |= ConformanceCheckFlags::SkipConditionalRequirements;
764-
765761
struct RequirementSet {
766762
ArrayRef<Requirement> Requirements;
767763
SmallVector<ParentConditionalConformance, 4> Parents;
@@ -819,14 +815,12 @@ RequirementCheckResult TypeChecker::checkGenericArguments(
819815
case RequirementKind::Conformance: {
820816
// Protocol conformance requirements.
821817
auto proto = secondType->castTo<ProtocolType>();
822-
// FIXME: This should track whether this should result in a private
823-
// or non-private dependency.
824-
// FIXME: Do we really need "used" at this point?
825818
// FIXME: Poor location information. How much better can we do here?
826819
// FIXME: This call should support listener to be able to properly
827820
// diagnose problems with conformances.
828821
auto conformance = conformsToProtocol(firstType, proto->getDecl(), dc,
829-
conformanceOptions, loc);
822+
ConformanceCheckFlags::SkipConditionalRequirements,
823+
loc);
830824

831825
if (conformance) {
832826
// Report the conformance.

lib/Sema/TypeCheckProtocol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3957,7 +3957,7 @@ void ConformanceChecker::ensureRequirementsAreSatisfied() {
39573957
proto->getRequirementSignature(),
39583958
QuerySubstitutionMap{substitutions},
39593959
TypeChecker::LookUpConformance(DC),
3960-
None, &listener);
3960+
&listener);
39613961

39623962
switch (result) {
39633963
case RequirementCheckResult::Success:
@@ -4435,7 +4435,7 @@ TypeChecker::conformsToProtocol(Type T, ProtocolDecl *Proto, DeclContext *DC,
44354435
DC, ComplainLoc, noteLoc, T,
44364436
{lookupResult.getRequirement()->getSelfInterfaceType()}, *condReqs,
44374437
[](SubstitutableType *dependentType) { return Type(dependentType); },
4438-
LookUpConformance(DC), options);
4438+
LookUpConformance(DC));
44394439
switch (conditionalCheckResult) {
44404440
case RequirementCheckResult::Success:
44414441
break;

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ bool AssociatedTypeInference::checkCurrentTypeWitnesses(
10981098
sanitizedRequirements,
10991099
QuerySubstitutionMap{substitutions},
11001100
TypeChecker::LookUpConformance(dc),
1101-
None, nullptr, options);
1101+
nullptr, options);
11021102
switch (result) {
11031103
case RequirementCheckResult::Failure:
11041104
++NumSolutionStatesFailedCheck;
@@ -1146,7 +1146,6 @@ bool AssociatedTypeInference::checkConstrainedExtension(ExtensionDecl *ext) {
11461146
ext->getGenericSignature()->getRequirements(),
11471147
QueryTypeSubstitutionMap{subs},
11481148
LookUpConformanceInModule(ext->getModuleContext()),
1149-
None,
11501149
nullptr, options)) {
11511150
case RequirementCheckResult::Success:
11521151
case RequirementCheckResult::SubstitutionFailure:

lib/Sema/TypeCheckType.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,7 @@ static Type checkContextualRequirements(Type type,
675675
genericSig->getGenericParams(),
676676
genericSig->getRequirements(),
677677
QueryTypeSubstitutionMap{subMap},
678-
TypeChecker::LookUpConformance(dc),
679-
None);
678+
TypeChecker::LookUpConformance(dc));
680679

681680
switch (result) {
682681
case RequirementCheckResult::Failure:
@@ -914,7 +913,7 @@ Type TypeChecker::applyUnboundGenericArguments(
914913
genericSig->getGenericParams(),
915914
genericSig->getRequirements(),
916915
QueryTypeSubstitutionMap{subs},
917-
LookUpConformance(dc), None);
916+
LookUpConformance(dc));
918917

919918
switch (result) {
920919
case RequirementCheckResult::Failure:

lib/Sema/TypeChecker.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -681,16 +681,13 @@ std::string gatherGenericParamBindingsText(
681681
/// \param requirements The requirements against which the generic arguments
682682
/// should be checked.
683683
/// \param substitutions Substitutions from interface types of the signature.
684-
/// \param conformanceOptions The flags to use when checking conformance
685-
/// requirement.
686684
/// \param listener The generic check listener used to pick requirements and
687685
/// notify callers about diagnosed errors.
688686
RequirementCheckResult checkGenericArguments(
689687
DeclContext *dc, SourceLoc loc, SourceLoc noteLoc, Type owner,
690688
TypeArrayView<GenericTypeParamType> genericParams,
691689
ArrayRef<Requirement> requirements, TypeSubstitutionFn substitutions,
692690
LookupConformanceFn conformances,
693-
ConformanceCheckOptions conformanceOptions,
694691
GenericRequirementsCheckListener *listener = nullptr,
695692
SubstOptions options = None);
696693

0 commit comments

Comments
 (0)