Stop trying to fully check a conformance when we query its existence.

This eliminates nonsensical recursion when working with protocol
conformances, and makes their checking more lazy. Start to improve
name lookup to deal with protocol witnesses more lazily, generalizing
the solution we had to all protocol conformances and making it more
directed. We're not done here, as the FIXMEs in the code completion
test imply: this replace-the-requirement-with-the-witness behavior
needs to be sunk down into the AST level so it also applies to
unqualified lookup, visible-decl lookup, etc.

Swift SVN r27639
This commit is contained in:
Doug Gregor
2015-04-23 18:20:57 +00:00
parent c45c5d4bd1
commit 4ae7b13820
6 changed files with 70 additions and 44 deletions

View File

@@ -694,7 +694,8 @@ ArrayRef<Substitution> BoundGenericType::getSubstitutions(
auto type = Type(archetype).subst(module, substitutions,
/*ignoreMissing=*/hasTypeVariables,
resolver);
assert(type && "Unable to perform type substitution");
if (!type)
type = ErrorType::get(module->getASTContext());
SmallVector<ProtocolConformance *, 4> conformances;
if (type->is<TypeVariableType>() || type->isDependentType()) {
@@ -714,7 +715,9 @@ ArrayRef<Substitution> BoundGenericType::getSubstitutions(
conformances.push_back(nullptr);
break;
case ConformanceKind::DoesNotConform:
llvm_unreachable("Couldn't find conformance");
if (type->is<ErrorType>())
conformances.push_back(nullptr);
break;
}
}
}