SourceKit: Fix indexing crash with protocol typealiases

The root cause is that NormalProtocolConformance::forEachValueWitness()
needs to skip protocol members that are not requirements.

Otherwise we end up passing such a non-requirement member down to
NormalProtocolConformance::getWitness() and hit an assert when we
cannot find it.

It looks like this code path was only ever hit from SourceKit.
The fix moves TypeChecker::isRequirement() to a method on ValueDecl,
and calls it in the right places.

Fixes <https://bugs.swift.org/browse/SR-3815>.
This commit is contained in:
Slava Pestov
2017-02-20 02:49:51 -08:00
parent 7dc8f7d3bd
commit 0bc802e7ad
10 changed files with 143 additions and 25 deletions

View File

@@ -321,6 +321,8 @@ void NormalProtocolConformance::setTypeWitness(
Witness NormalProtocolConformance::getWitness(ValueDecl *requirement,
LazyResolver *resolver) const {
assert(!isa<AssociatedTypeDecl>(requirement) && "Request type witness");
assert(requirement->isProtocolRequirement() && "Not a requirement");
if (Resolver)
resolveLazyInfo();