Drop GetDeclContext from parse, errors will be diagnosed in check (#3468)

The criteria being enforced is not correct since `final` and `default`
functions in interfaces have definitions.
This commit is contained in:
josh11b
2023-12-07 16:35:57 +00:00
committed by GitHub
parent 18d7ba9542
commit 2e29b48d26
8 changed files with 78 additions and 130 deletions
-24
View File
@@ -417,30 +417,6 @@ auto Context::ConsumeListToken(NodeKind comma_kind, Lex::TokenKind close_kind,
}
}
auto Context::GetDeclContext() -> DeclContext {
// i == 0 is the file-level DeclScopeLoop. Additionally, i == 1 can be
// skipped because it will never be a DeclScopeLoop.
for (int i = state_stack_.size() - 1; i > 1; --i) {
// The declaration context is always the state _above_ a
// DeclScopeLoop.
if (state_stack_[i].state == State::DeclScopeLoop) {
switch (state_stack_[i - 1].state) {
case State::TypeDefinitionFinishAsClass:
return DeclContext::Class;
case State::TypeDefinitionFinishAsInterface:
return DeclContext::Interface;
case State::TypeDefinitionFinishAsNamedConstraint:
return DeclContext::NamedConstraint;
default:
llvm_unreachable("Missing handling for a declaration scope");
}
}
}
CARBON_CHECK(!state_stack_.empty() &&
state_stack_[0].state == State::DeclScopeLoop);
return DeclContext::File;
}
auto Context::RecoverFromDeclError(StateStackEntry state,
NodeKind parse_node_kind,
bool skip_past_likely_end) -> void {