Verify that a function's DeclName, TuplePattern, and ParamDecls are in sync.

This required a few changes in places where we synthesize functions to
make sure these properties hold. That's good because we don't know where
we might already be depending on them. (On the other hand, we could also
decide not to care about TuplePattern labels, in which case I wonder if
we could eventually discard them altogether in functions.)

Still untested: that the function type is also in sync.
This commit is contained in:
Jordan Rose
2015-10-28 18:05:01 -07:00
parent 3a1fad6d55
commit 070ccba166
4 changed files with 90 additions and 3 deletions

View File

@@ -155,9 +155,10 @@ static Pattern *buildIndexForwardingPattern(AbstractStorageDecl *storage,
// Clone index patterns in a manner that allows them to be
// perfectly forwarded.
DeclContext *DC = storage->getDeclContext();
auto addVarPatternFor = [&](Pattern *P) {
auto addVarPatternFor = [&](Pattern *P, Identifier label = Identifier()) {
Pattern *vp = P->cloneForwardable(TC.Context, DC, Pattern::Implicit);
elements.push_back(TuplePatternElt(vp));
elements.back().setLabel(label, SourceLoc());
};
// This is the same breakdown the parser does.
@@ -167,7 +168,7 @@ static Pattern *buildIndexForwardingPattern(AbstractStorageDecl *storage,
} else {
auto tp = cast<TuplePattern>(indices);
for (auto &element : tp->getElements()) {
addVarPatternFor(element.getPattern());
addVarPatternFor(element.getPattern(), element.getLabel());
}
}