Skip to content

Commit

Permalink
GSB: ignore generic types in expandConformanceRequirement
Browse files Browse the repository at this point in the history
Fixes crashes in 28437-swift-typechecker-validatedecl.swift (from previous commit)
and the compiler crasher 28861-gpdecl-getdepth-generictypeparamdecl-
invaliddepth-parameter-hasnt-been-validated.swift.
  • Loading branch information
xymus committed Apr 30, 2019
1 parent c27dca3 commit bddb40d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion lib/AST/GenericSignatureBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4163,8 +4163,14 @@ ConstraintResult GenericSignatureBuilder::expandConformanceRequirement(
if (inheritedProto == proto) return TypeWalker::Action::Continue;

for (auto req : inheritedProto->getMembers()) {
if (auto typeReq = dyn_cast<TypeDecl>(req))
if (auto typeReq = dyn_cast<TypeDecl>(req)) {
// Ignore generic types
if (auto genReq = dyn_cast<GenericTypeDecl>(req))
if (genReq->getGenericParams())
continue;

inheritedTypeDecls[typeReq->getFullName()].push_back(typeReq);
}
}
return TypeWalker::Action::Continue;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors

// REQUIRES: asserts
// RUN: not --crash %target-swift-frontend %s -emit-ir
// RUN: not %target-swift-frontend %s -emit-ir
protocol
P{protocol A:P{{}}typealias e:A{}class a<a{}class a

0 comments on commit bddb40d

Please sign in to comment.