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
-12
View File
@@ -46,18 +46,6 @@ auto HandleFunctionSignatureFinish(Context& context) -> void {
break;
}
case Lex::TokenKind::OpenCurlyBrace: {
if (auto decl_context = context.GetDeclContext();
decl_context == Context::DeclContext::Interface ||
decl_context == Context::DeclContext::NamedConstraint) {
CARBON_DIAGNOSTIC(
MethodImplNotAllowed, Error,
"Method implementations are not allowed in interfaces.");
context.emitter().Emit(*context.position(), MethodImplNotAllowed);
context.RecoverFromDeclError(state, NodeKind::FunctionDecl,
/*skip_past_likely_end=*/true);
break;
}
context.AddNode(NodeKind::FunctionDefinitionStart, context.Consume(),
state.subtree_start, state.has_error);
// Any error is recorded on the FunctionDefinitionStart.