Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 13 additions & 9 deletions lib/AST/GenericSignature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,22 @@ GenericSignatureImpl::GenericSignatureImpl(

TypeArrayView<GenericTypeParamType>
GenericSignatureImpl::getInnermostGenericParams() const {
auto params = getGenericParams();
const auto params = getGenericParams();

// Find the point at which the depth changes.
unsigned depth = params.back()->getDepth();
for (unsigned n = params.size(); n > 0; --n) {
if (params[n-1]->getDepth() != depth) {
return params.slice(n);
}
const unsigned maxDepth = params.back()->getDepth();
if (params.front()->getDepth() == maxDepth)
return params;

// There is a depth change. Count the number of elements
// to slice off the front.
unsigned sliceCount = params.size() - 1;
while (true) {
if (params[sliceCount - 1]->getDepth() != maxDepth)
break;
--sliceCount;
}

// All parameters are at the same depth.
return params;
return params.slice(sliceCount);
}

void GenericSignatureImpl::forEachParam(
Expand Down