AST: Cache protocol generic signature in GenericContext::getGenericSignature()

The generic signature of a protocol is simple enough that we can
build it directly when asked. However, be sure to cache it for
future use.
This commit is contained in:
Slava Pestov
2019-01-08 16:24:50 -05:00
parent 1e27f21ed2
commit 716ac81b3e
4 changed files with 62 additions and 25 deletions

View File

@@ -583,7 +583,11 @@ Type ConstraintSystem::openType(Type type, OpenedTypeMap &replacements) {
if (auto genericParam = type->getAs<GenericTypeParamType>()) {
auto known = replacements.find(
cast<GenericTypeParamType>(genericParam->getCanonicalType()));
assert(known != replacements.end());
// FIXME: This should be an assert, however protocol generic signatures
// drop outer generic parameters.
// assert(known != replacements.end());
if (known == replacements.end())
return ErrorType::get(TC.Context);
return known->second;
}