[SIL Box types] Handle box types with layouts with non-parameter requirements.

The handling of SIL box types in both deserialization and in the SIL
parser assumed that the number of substitutions in the box type would
be equivalent to the number of generic parameters. This assumption is
incorrect when the generic signature adds requirements to an
associated type.

Fixes rdar://problem/29740594.
This commit is contained in:
Doug Gregor
2017-01-03 13:57:51 -08:00
parent 6705350ab7
commit 2706904bf6
3 changed files with 19 additions and 4 deletions

View File

@@ -4007,13 +4007,13 @@ Type ModuleFile::getType(TypeID TID) {
SmallVector<Substitution, 4> genericArgs;
if (auto sig = layout->getGenericSignature()) {
if (args.size() != sig->getGenericParams().size()) {
if (args.size() != sig->getAllDependentTypes().size()) {
error();
return nullptr;
}
TypeSubstitutionMap mappings;
for (unsigned i : indices(args)) {
for (unsigned i : indices(sig->getGenericParams())) {
mappings[sig->getGenericParams()[i]] =
getType(args[i])->getCanonicalType();
}