Defer building thunks until the end of the enclosing definition. (#5403)

Instead of building the definition of a thunk immediately when we
generate the thunk declaration, wait until we reach the `}` of the
outermost class, interface, etc. -- at the same time when we would parse
the definition of the thunk if it were defined inline.

This fixes issues where we fail to define the thunk because it requires
an enclosing class to be complete, or its definition depends on
something declared later in the enclosing class.

Make the representation of a suspended function scope, and its
constituent suspended components, be move-only, and switch to passing it
around by rvalue reference instead of by value because it's expensive
both to move and especially to copy.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
Richard SmithandJon Ross-Perkins authored and GitHub committed 2025-05-07 22:20:39 +00:00
1 parent 6f32a003d2
commit e060342411
21 files changed
+629 -259

No files matched your search

+1 -1
View File
@@ -286,7 +286,7 @@ auto ScopeStack::Suspend() -> SuspendedScope {
return result;
}
auto ScopeStack::Restore(SuspendedScope scope) -> void {
auto ScopeStack::Restore(SuspendedScope&& scope) -> void {
compile_time_binding_stack_.PushArray();
for (auto [index, inst_id] : scope.suspended_items) {
if (index == SuspendedScope::ScopeItem::IndexForCompileTimeBinding) {