Fix SILGenFunction::emitBasicProlog for @lifetime with default args.

LifetimeDependencies were being read from the wrong DeclContext.

Fixes rdar://142451893 (Crash during AST -> SIL lowering)
This commit is contained in:
Andrew Trick
2025-01-09 22:14:37 -08:00
parent 635ea34bb5
commit 03ae24daa9
2 changed files with 14 additions and 3 deletions

View File

@@ -1643,9 +1643,12 @@ uint16_t SILGenFunction::emitBasicProlog(
emitIndirectErrorParameter(*this, *errorType, *origErrorType, DC);
}
// Parameters with scoped dependencies may lower differently.
// Parameters with scoped dependencies may lower differently. Parameters are
// relative to the current SILGenFunction, not the passed in DeclContext. For
// example, the an argument initializer's DeclContext is the enclosing
// function definition rather that the initializer's generator function.
llvm::SmallPtrSet<ParamDecl *, 2> scopedDependencyParams;
if (auto afd = dyn_cast<AbstractFunctionDecl>(DC)) {
if (auto afd = dyn_cast<AbstractFunctionDecl>(FunctionDC)) {
if (auto deps = afd->getLifetimeDependencies()) {
for (auto &dep : *deps) {
auto scoped = dep.getScopeIndices();