mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
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:
co-authored by
Jon Ross-Perkins
parent
6f32a003d2
commit
e060342411
@@ -108,7 +108,7 @@ auto DeclNameStack::Suspend() -> SuspendedName {
|
||||
return result;
|
||||
}
|
||||
|
||||
auto DeclNameStack::Restore(SuspendedName sus) -> void {
|
||||
auto DeclNameStack::Restore(SuspendedName&& sus) -> void {
|
||||
// The parent state must be the same when a name is restored.
|
||||
CARBON_CHECK(context_->scope_stack().PeekIndex() ==
|
||||
sus.name_context.initial_scope_index,
|
||||
|
||||
Reference in New Issue
Block a user