Sema: Fix yet another crash when accessing nested types of an existential

We diagnose usage of invalid existential types but we might still
try to compute substitutions. Just whip up an ErrorType instead.

Fixes <rdar://problem/16803384>.

Swift SVN r29567
This commit is contained in:
Slava Pestov
2015-06-23 06:39:22 +00:00
parent 3e3ff0bba7
commit 665b870f7f
5 changed files with 67 additions and 19 deletions

View File

@@ -1082,6 +1082,13 @@ ConstraintSystem::getTypeOfMemberReference(Type baseTy, ValueDecl *value,
// Handle associated type lookup as a special case, horribly.
// FIXME: This is an awful hack.
if (auto assocType = dyn_cast<AssociatedTypeDecl>(value)) {
// Error recovery path.
if (baseObjTy->isOpenedExistential()) {
Type memberTy = ErrorType::get(TC.Context);
auto openedType = FunctionType::get(baseObjTy, memberTy);
return { openedType, memberTy };
}
// Refer to a member of the archetype directly.
if (auto archetype = baseObjTy->getAs<ArchetypeType>()) {
Type memberTy = archetype->getNestedTypeValue(value->getName());