Take first steps towards simplifying the constraint graph by performing edge contraction.

This commit is contained in:
Joe Pamer
2015-12-03 15:52:57 -08:00
parent c64b78c5bc
commit 37032b2a58
5 changed files with 106 additions and 1 deletions

View File

@@ -1323,9 +1323,20 @@ ConstraintSystem::matchTypes(Type type1, Type type2, TypeMatchKind kind,
}
SWIFT_FALLTHROUGH;
case TypeMatchKind::Conversion:
if (typeVar1 && typeVar2) {
auto rep1 = getRepresentative(typeVar1);
auto rep2 = getRepresentative(typeVar2);
if (rep1 == rep2) {
// We already merged these two types, so this constraint is
// trivially solved.
return SolutionKind::Solved;
}
}
SWIFT_FALLTHROUGH;
case TypeMatchKind::ConformsTo:
case TypeMatchKind::Subtype:
case TypeMatchKind::Conversion:
case TypeMatchKind::ExplicitConversion:
case TypeMatchKind::ArgumentConversion:
case TypeMatchKind::OperatorArgumentTupleConversion: