mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 18:51:09 +01:00
Basic support for parameterized interfaces. (#1220)
To make this work, introduce impl bindings into scope immediately when type-checking. We may rely on their existence before we finish type-checking the enclosing pattern.
This commit is contained in:
@@ -289,30 +289,37 @@ class InterfaceDeclaration : public Declaration {
|
||||
using ImplementsCarbonValueNode = void;
|
||||
|
||||
InterfaceDeclaration(SourceLocation source_loc, std::string name,
|
||||
std::optional<Nonnull<TuplePattern*>> params,
|
||||
Nonnull<GenericBinding*> self,
|
||||
std::vector<Nonnull<Declaration*>> members)
|
||||
: Declaration(AstNodeKind::InterfaceDeclaration, source_loc),
|
||||
name_(std::move(name)),
|
||||
members_(std::move(members)),
|
||||
self_(self) {}
|
||||
params_(std::move(params)),
|
||||
self_(self),
|
||||
members_(std::move(members)) {}
|
||||
|
||||
static auto classof(const AstNode* node) -> bool {
|
||||
return InheritsFromInterfaceDeclaration(node->kind());
|
||||
}
|
||||
|
||||
auto name() const -> const std::string& { return name_; }
|
||||
auto params() const -> std::optional<Nonnull<const TuplePattern*>> {
|
||||
return params_;
|
||||
}
|
||||
auto params() -> std::optional<Nonnull<TuplePattern*>> { return params_; }
|
||||
auto self() const -> Nonnull<const GenericBinding*> { return self_; }
|
||||
auto self() -> Nonnull<GenericBinding*> { return self_; }
|
||||
auto members() const -> llvm::ArrayRef<Nonnull<Declaration*>> {
|
||||
return members_;
|
||||
}
|
||||
auto self() const -> Nonnull<const GenericBinding*> { return self_; }
|
||||
auto self() -> Nonnull<GenericBinding*> { return self_; }
|
||||
|
||||
auto value_category() const -> ValueCategory { return ValueCategory::Let; }
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
std::vector<Nonnull<Declaration*>> members_;
|
||||
std::optional<Nonnull<TuplePattern*>> params_;
|
||||
Nonnull<GenericBinding*> self_;
|
||||
std::vector<Nonnull<Declaration*>> members_;
|
||||
};
|
||||
|
||||
enum class ImplKind { InternalImpl, ExternalImpl };
|
||||
|
||||
Reference in New Issue
Block a user