[CSSyntacticElement] Bring type variables from outer pack expansion into scope

If closure appears inside of a pack expansion, the elements
that reference pack elements have to bring expansion's shape
type in scope to make sure that the shapes match.
This commit is contained in:
Pavel Yaskevich
2024-05-22 14:43:10 -07:00
parent 888ab81c1e
commit bc3b2748bc
2 changed files with 12 additions and 3 deletions

View File

@@ -153,6 +153,17 @@ public:
}
}
// If closure appears inside of a pack expansion, the elements
// that reference pack elements have to bring expansion's shape
// type in scope to make sure that the shapes match.
if (auto *packElement = getAsExpr<PackElementExpr>(expr)) {
if (auto *outerEnvironment = CS.getPackEnvironment(packElement)) {
auto *expansionTy = CS.simplifyType(CS.getType(outerEnvironment))
->castTo<PackExpansionType>();
expansionTy->getCountType()->getTypeVariables(ReferencedVars);
}
}
return Action::Continue(expr);
}