Handle use-before-declare in static name lookup (#967)

Also remove inheritance from NamedEntity for some classes that don't need it.
This commit is contained in:
Geoff Romer
2021-12-03 13:52:31 -08:00
committed by GitHub
parent b83f00225a
commit f75b4d322f
14 changed files with 163 additions and 266 deletions
-11
View File
@@ -20,7 +20,6 @@
namespace Carbon {
class FunctionDeclaration;
class StaticScope;
class Statement : public virtual AstNode {
public:
@@ -60,12 +59,8 @@ class Block : public Statement {
return statements_;
}
auto static_scope() const -> const StaticScope& { return static_scope_; }
auto static_scope() -> StaticScope& { return static_scope_; }
private:
std::vector<Nonnull<Statement*>> statements_;
StaticScope static_scope_;
};
class ExpressionStatement : public Statement {
@@ -283,15 +278,9 @@ class Match : public Statement {
auto statement() const -> const Statement& { return *statement_; }
auto statement() -> Statement& { return *statement_; }
// Contains names for the pattern and statement. Note that when the
// statement is a block, it gains its own scope.
auto static_scope() const -> const StaticScope& { return static_scope_; }
auto static_scope() -> StaticScope& { return static_scope_; }
private:
Nonnull<Pattern*> pattern_;
Nonnull<Statement*> statement_;
StaticScope static_scope_;
};
Match(SourceLocation source_loc, Nonnull<Expression*> expression,