mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user