Sema: Fix crash with protocol erroneously nested inside generic class

The protocol Self parameter is the last generic parameter in the signature,
not the first. While we don't allow protocols nested inside generic classes,
we would still crash in member type lookup from this.

Fixes <rdar://problem/21287703>.

Swift SVN r30635
This commit is contained in:
Slava Pestov
2015-07-25 19:55:12 +00:00
parent ec603ce37b
commit 0af2b4709f
7 changed files with 53 additions and 7 deletions

View File

@@ -1719,7 +1719,7 @@ Type ValueDecl::getInterfaceType() const {
if (auto assocType = dyn_cast<AssociatedTypeDecl>(this)) {
auto proto = cast<ProtocolDecl>(getDeclContext());
(void)proto->getType(); // make sure we've computed the type.
auto selfTy = proto->getGenericParamTypes()[0];
auto selfTy = proto->getGenericParamTypes().back();
auto &ctx = getASTContext();
InterfaceTy = DependentMemberType::get(
selfTy,