Merge pull request #28275 from slavapestov/check-where-clause-non-generic-type

Check generic requirements of parent context when realizing non-generic types
This commit is contained in:
Slava Pestov
2019-11-15 08:46:04 -05:00
committed by GitHub
9 changed files with 224 additions and 161 deletions

View File

@@ -677,8 +677,6 @@ Type ConstraintSystem::openUnboundGenericType(
Type type, ConstraintLocatorBuilder locator) {
assert(!type->getCanonicalType()->hasTypeParameter());
checkNestedTypeConstraints(*this, type, locator);
if (!type->hasUnboundGenericType())
return type;
@@ -1036,6 +1034,8 @@ ConstraintSystem::getTypeOfReference(ValueDecl *value,
TypeResolverContext::InExpression,
/*isSpecialized=*/false);
checkNestedTypeConstraints(*this, type, locator);
// Open the type.
type = openUnboundGenericType(type, locator);
@@ -1289,6 +1289,9 @@ ConstraintSystem::getTypeOfMemberReference(
auto memberTy = TypeChecker::substMemberTypeWithBase(DC->getParentModule(),
typeDecl, baseObjTy);
checkNestedTypeConstraints(*this, memberTy, locator);
// Open the type if it was a reference to a generic type.
memberTy = openUnboundGenericType(memberTy, locator);