Skip to content

Commit 7e17aaf

Browse files
committed
GSB: Remove one of the two overloads of checkConstraintList()
1 parent 61f796d commit 7e17aaf

File tree

2 files changed

+17
-71
lines changed

2 files changed

+17
-71
lines changed

include/swift/AST/GenericSignatureBuilder.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -706,34 +706,6 @@ class GenericSignatureBuilder {
706706
Diag<Type, T> redundancyDiag,
707707
Diag<unsigned, Type, T> otherNoteDiag);
708708

709-
/// Check a list of constraints, removing self-derived constraints
710-
/// and diagnosing redundant constraints.
711-
///
712-
/// \param isSuitableRepresentative Determines whether the given constraint
713-
/// is a suitable representative.
714-
///
715-
/// \param checkConstraint Checks the given constraint against the
716-
/// canonical constraint to determine which diagnostics (if any) should be
717-
/// emitted.
718-
///
719-
/// \returns the representative constraint.
720-
template<typename T, typename DiagT>
721-
Constraint<T> checkConstraintList(
722-
TypeArrayView<GenericTypeParamType> genericParams,
723-
std::vector<Constraint<T>> &constraints,
724-
RequirementKind kind,
725-
llvm::function_ref<bool(const Constraint<T> &)>
726-
isSuitableRepresentative,
727-
llvm::function_ref<
728-
ConstraintRelation(const Constraint<T>&)>
729-
checkConstraint,
730-
Optional<Diag<unsigned, Type, DiagT, DiagT>>
731-
conflictingDiag,
732-
Diag<Type, DiagT> redundancyDiag,
733-
Diag<unsigned, Type, DiagT> otherNoteDiag,
734-
llvm::function_ref<DiagT(const T&)> diagValue,
735-
bool removeSelfDerived);
736-
737709
/// Check the concrete type constraints within the equivalence
738710
/// class of the given potential archetype.
739711
void checkConcreteTypeConstraints(

lib/AST/GenericSignatureBuilder.cpp

Lines changed: 17 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6852,28 +6852,6 @@ void GenericSignatureBuilder::processDelayedRequirements() {
68526852
} while (anySolved);
68536853
}
68546854

6855-
template<typename T>
6856-
Constraint<T> GenericSignatureBuilder::checkConstraintList(
6857-
TypeArrayView<GenericTypeParamType> genericParams,
6858-
std::vector<Constraint<T>> &constraints,
6859-
RequirementKind kind,
6860-
llvm::function_ref<bool(const Constraint<T> &)>
6861-
isSuitableRepresentative,
6862-
llvm::function_ref<
6863-
ConstraintRelation(const Constraint<T>&)>
6864-
checkConstraint,
6865-
Optional<Diag<unsigned, Type, T, T>>
6866-
conflictingDiag,
6867-
Diag<Type, T> redundancyDiag,
6868-
Diag<unsigned, Type, T> otherNoteDiag) {
6869-
return checkConstraintList<T, T>(genericParams, constraints, kind,
6870-
isSuitableRepresentative, checkConstraint,
6871-
conflictingDiag, redundancyDiag,
6872-
otherNoteDiag,
6873-
[](const T& value) { return value; },
6874-
/*removeSelfDerived=*/true);
6875-
}
6876-
68776855
namespace {
68786856
/// Remove self-derived sources from the given vector of constraints.
68796857
///
@@ -6957,7 +6935,7 @@ namespace {
69576935
}
69586936
} // end anonymous namespace
69596937

6960-
template<typename T, typename DiagT>
6938+
template<typename T>
69616939
Constraint<T> GenericSignatureBuilder::checkConstraintList(
69626940
TypeArrayView<GenericTypeParamType> genericParams,
69636941
std::vector<Constraint<T>> &constraints,
@@ -6967,16 +6945,11 @@ Constraint<T> GenericSignatureBuilder::checkConstraintList(
69676945
llvm::function_ref<
69686946
ConstraintRelation(const Constraint<T>&)>
69696947
checkConstraint,
6970-
Optional<Diag<unsigned, Type, DiagT, DiagT>>
6948+
Optional<Diag<unsigned, Type, T, T>>
69716949
conflictingDiag,
6972-
Diag<Type, DiagT> redundancyDiag,
6973-
Diag<unsigned, Type, DiagT> otherNoteDiag,
6974-
llvm::function_ref<DiagT(const T&)> diagValue,
6975-
bool removeSelfDerived) {
6950+
Diag<Type, T> redundancyDiag,
6951+
Diag<unsigned, Type, T> otherNoteDiag) {
69766952
assert(!constraints.empty() && "No constraints?");
6977-
if (removeSelfDerived) {
6978-
::removeSelfDerived(*this, constraints, /*proto=*/nullptr);
6979-
}
69806953

69816954
// Sort the constraints, so we get a deterministic ordering of diagnostics.
69826955
std::sort(constraints.begin(), constraints.end());
@@ -6995,7 +6968,7 @@ Constraint<T> GenericSignatureBuilder::checkConstraintList(
69956968
representativeConstraint->source->classifyDiagKind(),
69966969
representativeConstraint->getSubjectDependentType(
69976970
genericParams),
6998-
diagValue(representativeConstraint->value));
6971+
representativeConstraint->value);
69996972
};
70006973

70016974
// Go through the concrete constraints looking for redundancies.
@@ -7041,8 +7014,8 @@ Constraint<T> GenericSignatureBuilder::checkConstraintList(
70417014
getSubjectType(constraint.getSubjectDependentType(genericParams));
70427015
Diags.diagnose(constraint.source->getLoc(), *conflictingDiag,
70437016
subject.first, subject.second,
7044-
diagValue(constraint.value),
7045-
diagValue(representativeConstraint->value));
7017+
constraint.value,
7018+
representativeConstraint->value);
70467019

70477020
noteRepresentativeConstraint();
70487021
break;
@@ -7060,8 +7033,8 @@ Constraint<T> GenericSignatureBuilder::checkConstraintList(
70607033
Diags.diagnose(representativeConstraint->source->getLoc(),
70617034
*conflictingDiag,
70627035
subject.first, subject.second,
7063-
diagValue(representativeConstraint->value),
7064-
diagValue(constraint.value));
7036+
representativeConstraint->value,
7037+
constraint.value);
70657038

70667039
diagnosedConflictingRepresentative = true;
70677040
break;
@@ -7078,7 +7051,7 @@ Constraint<T> GenericSignatureBuilder::checkConstraintList(
70787051
Diags.diagnose(constraint.source->getLoc(),
70797052
redundancyDiag,
70807053
constraint.getSubjectDependentType(genericParams),
7081-
diagValue(constraint.value));
7054+
constraint.value);
70827055

70837056
noteRepresentativeConstraint();
70847057
}
@@ -7935,7 +7908,7 @@ void GenericSignatureBuilder::checkSameTypeConstraints(
79357908
for (auto &constraints : intracomponentEdges) {
79367909
if (constraints.empty()) continue;
79377910

7938-
checkConstraintList<Type, Type>(
7911+
checkConstraintList<Type>(
79397912
genericParams, constraints, RequirementKind::SameType,
79407913
[](const Constraint<Type> &) { return true; },
79417914
[](const Constraint<Type> &constraint) {
@@ -7948,11 +7921,7 @@ void GenericSignatureBuilder::checkSameTypeConstraints(
79487921
},
79497922
None,
79507923
diag::redundant_same_type_constraint,
7951-
diag::previous_same_type_constraint,
7952-
[&](Type type) {
7953-
return type;
7954-
},
7955-
/*removeSelfDerived=*/false);
7924+
diag::previous_same_type_constraint);
79567925
}
79577926

79587927
// Diagnose redundant same-type constraints across components. First,
@@ -8128,6 +8097,11 @@ void GenericSignatureBuilder::checkConcreteTypeConstraints(
81288097
Type resolvedConcreteType =
81298098
getCanonicalTypeInContext(equivClass->concreteType, genericParams);
81308099

8100+
removeSelfDerived(*this, equivClass->concreteTypeConstraints,
8101+
/*proto=*/nullptr,
8102+
/*dropDerivedViaConcrete=*/true,
8103+
/*allCanBeSelfDerived=*/true);
8104+
81318105
checkConstraintList<Type>(
81328106
genericParams, equivClass->concreteTypeConstraints, RequirementKind::SameType,
81338107
[&](const ConcreteConstraint &constraint) {

0 commit comments

Comments
 (0)