[Constraint solver] Clean up existential metatype handling.

Our existential metatype conversion/conformance handling in the type
checker was tripped up the refactoring to lazily introduce
constraints, because it dependended on the otherwise-unused
TypeMatchKind::ConformsTo. Eliminate TypeMatchKind::ConformsTo and
simplify the code here.
This commit is contained in:
Doug Gregor
2016-10-21 13:59:49 -07:00
parent 7519d83007
commit 41cd760682
3 changed files with 61 additions and 45 deletions

View File

@@ -507,6 +507,12 @@ Constraint *Constraint::create(ConstraintSystem &cs, ConstraintKind kind,
second->getTypeVariables(typeVars);
uniqueTypeVariables(typeVars);
// Conformance constraints expect a protocol on the right-hand side, always.
assert((kind != ConstraintKind::ConformsTo &&
kind != ConstraintKind::LiteralConformsTo &&
kind != ConstraintKind::SelfObjectOfProtocol) ||
second->is<ProtocolType>());
// Create the constraint.
unsigned size = totalSizeToAlloc<TypeVariableType*>(typeVars.size());
void *mem = cs.getAllocator().Allocate(size, alignof(Constraint));