[GSB] Diagnose all same-type-to-concrete conflicts consistently.

This commit is contained in:
Doug Gregor
2017-06-05 16:30:36 -07:00
parent bf730fff08
commit b51529f9e7
3 changed files with 45 additions and 22 deletions

View File

@@ -1728,6 +1728,7 @@ namespace {
PotentialArchetype *pa;
void operator()(Type type1, Type type2) const {
// FIXME: Shouldn't need this!
if (pa->getParent() && pa->getConcreteTypeDecl() &&
source->getLoc().isInvalid()) {
diags.diagnose(pa->getConcreteTypeDecl()->getLoc(),
@@ -1736,14 +1737,6 @@ namespace {
type1, type2);
return;
}
if (source->getLoc().isValid()) {
diags.diagnose(source->getLoc(),
diag::requires_same_type_conflict,
pa->isGenericParam(),
pa->getDependentType(/*FIXME: */{ }, true),
type1, type2);
}
}
};
} // end anonymous namespace
@@ -5010,8 +5003,8 @@ void GenericSignatureBuilder::checkConcreteTypeConstraints(
checkConstraintList<Type>(
genericParams, equivClass->concreteTypeConstraints,
[](const ConcreteConstraint &constraint) {
return true;
[&](const ConcreteConstraint &constraint) {
return constraint.value->isEqual(equivClass->concreteType);
},
[&](Type concreteType) {
// If the concrete type is equivalent, the constraint is redundant.
@@ -5020,10 +5013,14 @@ void GenericSignatureBuilder::checkConcreteTypeConstraints(
if (concreteType->isEqual(equivClass->concreteType))
return ConstraintRelation::Redundant;
// Call this unrelated.
return ConstraintRelation::Unrelated;
// If either has a type parameter, call them unrelated.
if (concreteType->hasTypeParameter() ||
equivClass->concreteType->hasTypeParameter())
return ConstraintRelation::Unrelated;
return ConstraintRelation::Conflicting;
},
None,
diag::same_type_conflict,
diag::redundant_same_type_to_concrete,
diag::same_type_redundancy_here);