mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-29 10:54:57 +01:00
Adds basic support for class functions and methods. (#1057)
* adding methods to the ast * pre commit stuff? * implementation of class functions * implemented methods * some cleanup * more cleanup * add newlines in test programs * pre-commit fixups * added include of return_term.h * a test of a method calling another method * replacing Member with Declaration * removing the member.h etc files * clarify a type annotation * update uses of FunctionDeclaration * remove ReturnTarget, no longer needed * more cleanup * more cleanup * yet more cleanup, playing with pre-commit * did a pre-commit run --all-files * fixed const issue * remove comment * checking dependencies in BUILD files and headers * pre-commit working now * refactor NominalClassType to just hold a pointer to the class declaration * remove Member from rtti * responding to Geoffreys review * change field_types to a non-member function
This commit is contained in:
@@ -104,7 +104,7 @@ TEST(MatchesReturnTest, BasicUsage) {
|
||||
TEST(MatchesFunctionDeclarationTest, BasicUsage) {
|
||||
TuplePattern params(DummyLoc, {});
|
||||
Block body(DummyLoc, {});
|
||||
FunctionDeclaration decl(DummyLoc, "Foo", {}, ¶ms,
|
||||
FunctionDeclaration decl(DummyLoc, "Foo", {}, std::nullopt, ¶ms,
|
||||
ReturnTerm::Omitted(DummyLoc), &body);
|
||||
|
||||
EXPECT_THAT(decl, MatchesFunctionDeclaration());
|
||||
@@ -117,7 +117,7 @@ TEST(MatchesFunctionDeclarationTest, BasicUsage) {
|
||||
EXPECT_THAT(decl,
|
||||
Not(MatchesFunctionDeclaration().WithBody(MatchesLiteral(0))));
|
||||
|
||||
FunctionDeclaration forward_decl(DummyLoc, "Foo", {}, ¶ms,
|
||||
FunctionDeclaration forward_decl(DummyLoc, "Foo", {}, std::nullopt, ¶ms,
|
||||
ReturnTerm::Omitted(DummyLoc), std::nullopt);
|
||||
EXPECT_THAT(forward_decl, MatchesFunctionDeclaration().WithName("Foo"));
|
||||
EXPECT_THAT(forward_decl, Not(MatchesFunctionDeclaration().WithBody(_)));
|
||||
@@ -150,7 +150,7 @@ TEST(MatchesUnimplementedExpressionTest, BasicUsage) {
|
||||
TEST(ASTDeclarationsTest, BasicUsage) {
|
||||
TuplePattern params(DummyLoc, {});
|
||||
Block body(DummyLoc, {});
|
||||
FunctionDeclaration decl(DummyLoc, "Foo", {}, ¶ms,
|
||||
FunctionDeclaration decl(DummyLoc, "Foo", {}, std::nullopt, ¶ms,
|
||||
ReturnTerm::Omitted(DummyLoc), &body);
|
||||
AST ast = {.declarations = {&decl}};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user