Resolve the definition of the self specific when re-entering its scope for an inline method definition. (#4281)

This fixes a crash if an inline method definition attempts to access a
member of the enclosing generic scope directly.

Fixes #4229.
This commit is contained in:
Richard Smith
2024-09-06 23:23:40 +00:00
committed by GitHub
parent a548eff0bb
commit a4fe9be2e4
4 changed files with 181 additions and 27 deletions
+6
View File
@@ -112,6 +112,12 @@ auto DeclNameStack::Restore(SuspendedName sus) -> void {
// NOLINTNEXTLINE(performance-move-const-arg)
decl_name_stack_.push_back(std::move(sus.name_context));
for (auto& suspended_scope : llvm::reverse(sus.scopes)) {
// Reattempt to resolve the definition of the specific. The generic might
// have been defined after we suspended this scope.
if (suspended_scope.entry.specific_id.is_valid()) {
ResolveSpecificDefinition(*context_, suspended_scope.entry.specific_id);
}
context_->scope_stack().Restore(std::move(suspended_scope));
}
}