mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Merge pull request #8263 from DougGregor/redundant-same-type-constraints
This commit is contained in:
@@ -1601,6 +1601,13 @@ NOTE(previous_layout_constraint, none,
|
||||
"layout constraint constraint %1 : %2 %select{written here|implied here}0",
|
||||
(bool, Type, LayoutConstraint))
|
||||
|
||||
WARNING(redundant_same_type_constraint,none,
|
||||
"redundant same-type constraint %0 == %1", (Type, Type))
|
||||
NOTE(previous_same_type_constraint, none,
|
||||
"previous same-type constraint %1 == %2 "
|
||||
"%select{written here|implied here}0",
|
||||
(bool, Type, Type))
|
||||
|
||||
ERROR(generic_param_access,none,
|
||||
"%0 %select{must be declared %select{"
|
||||
"%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
|
||||
|
||||
@@ -137,6 +137,22 @@ public:
|
||||
/// The members of the equivalence class.
|
||||
TinyPtrVector<PotentialArchetype *> members;
|
||||
|
||||
/// Describes a component within the graph of same-type constraints within
|
||||
/// the equivalence class that is held together by derived constraints.
|
||||
struct DerivedSameTypeComponent {
|
||||
/// The potential archetype that acts as the anchor for this component.
|
||||
PotentialArchetype *anchor;
|
||||
|
||||
/// The (best) requirement source within the component that makes the
|
||||
/// potential archetypes in this component equivalent to the concrete
|
||||
/// type.
|
||||
const RequirementSource *concreteTypeSource;
|
||||
};
|
||||
|
||||
/// The set of connected components within this equivalence class, using
|
||||
/// only the derived same-type constraints in the graph.
|
||||
std::vector<DerivedSameTypeComponent> derivedSameTypeComponents;
|
||||
|
||||
/// Construct a new equivalence class containing only the given
|
||||
/// potential archetype (which represents itself).
|
||||
EquivalenceClass(PotentialArchetype *representative);
|
||||
@@ -462,6 +478,32 @@ private:
|
||||
Diag<Type, T> redundancyDiag,
|
||||
Diag<bool, Type, T> otherNoteDiag);
|
||||
|
||||
/// Check a list of constraints, removing self-derived constraints
|
||||
/// and diagnosing redundant constraints.
|
||||
///
|
||||
/// \param isSuitableRepresentative Determines whether the given constraint
|
||||
/// is a suitable representative.
|
||||
///
|
||||
/// \param checkConstraint Checks the given constraint against the
|
||||
/// canonical constraint to determine which diagnostics (if any) should be
|
||||
/// emitted.
|
||||
///
|
||||
/// \returns the representative constraint.
|
||||
template<typename T, typename DiagT>
|
||||
Constraint<T> checkConstraintList(
|
||||
ArrayRef<GenericTypeParamType *> genericParams,
|
||||
std::vector<Constraint<T>> &constraints,
|
||||
llvm::function_ref<bool(const Constraint<T> &)>
|
||||
isSuitableRepresentative,
|
||||
llvm::function_ref<ConstraintRelation(const T&)>
|
||||
checkConstraint,
|
||||
Optional<Diag<unsigned, Type, DiagT, DiagT>>
|
||||
conflictingDiag,
|
||||
Diag<Type, DiagT> redundancyDiag,
|
||||
Diag<bool, Type, DiagT> otherNoteDiag,
|
||||
llvm::function_ref<DiagT(const T&)> diagValue,
|
||||
bool removeSelfDerived);
|
||||
|
||||
/// Check the concrete type constraints within the equivalence
|
||||
/// class of the given potential archetype.
|
||||
void checkConcreteTypeConstraints(
|
||||
|
||||
Reference in New Issue
Block a user