mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-15 15:38:10 +00:00
`FinishAst` resolves C++ template instantiation. Template instantiation can complete Carbon types, generate thunks, and call generic functions. These operations can add new entries to `definitions_required_by_use()`. Similarly, resolving any of those can generate more C++ templates that need instantiating. This change moves `FinishAst` ahead of `CheckRequiredDefinitions` and loops until no new Carbon definitions have been added. This prevents later passes from crashing when evaluating specifics on unresolved generics or uninstantiated templates. `FinishAst` also disconnects the AST. Subsequent definitions and `impl`s may depend on C++ interop, so the AST must remain connected until all the Carbon end-of-file checks complete. We achieve this by decoupling AST disconnection from finalisation. Assisted-by: Antigravity with Gemini Assisted-by: Antigravity with Claude Opus 5.5 Max