Sema: Convert TypeChecker::computeCaptures() into two requests

We now compute captures of functions and default arguments
lazily, instead of as a side effect of primary file checking.

Captures of closures are computed as part of the enclosing
context, not lazily, because the type checking of a single
closure body is not lazy.

This fixes a specific issue with the `-experimental-skip-*` flags,
where functions declared after a top-level `guard` statement are
considered to have local captures, but nothing was forcing these
captures to be computed.

Fixes rdar://problem/125981663.
This commit is contained in:
Slava Pestov
2024-04-12 17:50:04 -04:00
parent 55ff73f205
commit e342a38b87
17 changed files with 229 additions and 78 deletions

View File

@@ -3468,6 +3468,7 @@ void SourceFile::typeCheckDelayedFunctions() {
auto *AFD = DelayedFunctions[i];
assert(!AFD->getDeclContext()->isLocalContext());
AFD->getTypecheckedBody();
(void) AFD->getCaptureInfo();
}
DelayedFunctions.clear();