mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 13:01:04 +01:00
Start populating named entities in relevant locations. (#919)
This starts detecting naming collisions as a consequence of being able to determine when the name is declared twice in a given scope. Co-authored-by: Geoff Romer <gromer@google.com>
This commit is contained in:
committed by
GitHub
co-authored by
Geoff Romer
parent
82a870cfcd
commit
27e084d37a
@@ -12,6 +12,7 @@
|
||||
#include "common/ostream.h"
|
||||
#include "executable_semantics/ast/expression.h"
|
||||
#include "executable_semantics/ast/source_location.h"
|
||||
#include "executable_semantics/ast/static_scope.h"
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
|
||||
namespace Carbon {
|
||||
@@ -100,7 +101,7 @@ class AutoPattern : public Pattern {
|
||||
|
||||
// A pattern that matches a value of a specified type, and optionally binds
|
||||
// a name to it.
|
||||
class BindingPattern : public Pattern {
|
||||
class BindingPattern : public Pattern, public NamedEntityInterface {
|
||||
public:
|
||||
BindingPattern(SourceLocation source_loc, std::optional<std::string> name,
|
||||
Nonnull<Pattern*> type)
|
||||
@@ -108,6 +109,14 @@ class BindingPattern : public Pattern {
|
||||
name_(std::move(name)),
|
||||
type_(type) {}
|
||||
|
||||
auto named_entity_kind() const -> NamedEntityKind override {
|
||||
return NamedEntityKind::BindingPattern;
|
||||
}
|
||||
|
||||
auto source_loc() const -> SourceLocation override {
|
||||
return Pattern::source_loc();
|
||||
}
|
||||
|
||||
static auto classof(const Pattern* pattern) -> bool {
|
||||
return pattern->kind() == Kind::BindingPattern;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user