mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 09:00:31 +00:00
Keep resolving generics and templates until they're all resolved (#7957)
`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
This commit is contained in:
1 parent
dd30c76556
commit
57bf903ef1
9 files changed
+286
-49
No files matched your search
@@ -591,7 +591,8 @@ auto ResolveReturnTypeInSpecific(Context& context, SemIR::LocId loc_id,
|
||||
|
||||
// Otherwise, the return type and the return pattern were created
|
||||
// within the definition of the generic, and are computed by its eval block.
|
||||
if (!ResolveSpecificDefinition(context, loc_id, specific_id)) {
|
||||
if (ResolveSpecificDefinition(context, loc_id, specific_id) ==
|
||||
DefinitionResolution::NotDefinedYet) {
|
||||
// We're within the definition of the function, after its return type was
|
||||
// deduced. In the self specific, the return type is just the deduced type,
|
||||
// but we can't compute it for any other specific until the definition is
|
||||
|
||||
Reference in new issue
Block a user