mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Basic support for impl virtual override keyword (#2493)
Features:
* Add basic support for `impl` virtual methods (override virtual method)
* Error on invalid declaration for `impl` and `virtual`, covering simple use cases
* Add `abstract` fn parser-only support
Changes:
* Modify parser to handle new function specifiers, resolve conflicts
* Group `virtual_override` and `FN`, and group `impl_kind` and `IMPL` to avoid ambiguities with around `impl` token parsing
* Add new `VirtualOverride` enum for function declarations, and matching `virt_override() -> VirtualOverride` getter
* Update function declaration logic
Depends on #2462
This commit is contained in:
@@ -103,7 +103,7 @@ TEST(MatchesFunctionDeclarationTest, BasicUsage) {
|
||||
Block body(DummyLoc, {});
|
||||
FunctionDeclaration decl(DummyLoc, "Foo", {}, std::nullopt, ¶ms,
|
||||
ReturnTerm::Omitted(DummyLoc), &body,
|
||||
/*is_virtual=*/false);
|
||||
VirtualOverride::None);
|
||||
|
||||
EXPECT_THAT(decl, MatchesFunctionDeclaration());
|
||||
EXPECT_THAT(&decl, MatchesFunctionDeclaration());
|
||||
@@ -117,7 +117,7 @@ TEST(MatchesFunctionDeclarationTest, BasicUsage) {
|
||||
|
||||
FunctionDeclaration forward_decl(DummyLoc, "Foo", {}, std::nullopt, ¶ms,
|
||||
ReturnTerm::Omitted(DummyLoc), std::nullopt,
|
||||
/*is_virtual=*/false);
|
||||
VirtualOverride::None);
|
||||
EXPECT_THAT(forward_decl, MatchesFunctionDeclaration().WithName("Foo"));
|
||||
EXPECT_THAT(forward_decl, Not(MatchesFunctionDeclaration().WithBody(_)));
|
||||
|
||||
@@ -151,7 +151,7 @@ TEST(ASTDeclarationsTest, BasicUsage) {
|
||||
Block body(DummyLoc, {});
|
||||
FunctionDeclaration decl(DummyLoc, "Foo", {}, std::nullopt, ¶ms,
|
||||
ReturnTerm::Omitted(DummyLoc), &body,
|
||||
/*is_virtual=*/false);
|
||||
VirtualOverride::None);
|
||||
AST ast = {.declarations = {&decl}};
|
||||
|
||||
EXPECT_THAT(ast, ASTDeclarations(ElementsAre(MatchesFunctionDeclaration())));
|
||||
|
||||
Reference in New Issue
Block a user