mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-26 22:02:30 +01:00
Parameterized impl declarations (#1189)
* parameterized impls, first step * bug fixes, comments, etc. * added another test case, fix a bug in impl lookup * simplify tests, removing tuple stuff * don't create impl bindings for -bound implicit parameters * remove a redundant 'private' * CamelCase * add missing backtick * add a comment
This commit is contained in:
@@ -211,6 +211,27 @@ void FunctionDeclaration::PrintDepth(int depth, llvm::raw_ostream& out) const {
|
||||
}
|
||||
}
|
||||
|
||||
auto ImplDeclaration::Create(Nonnull<Arena*> arena, SourceLocation source_loc,
|
||||
ImplKind kind, Nonnull<Expression*> impl_type,
|
||||
Nonnull<Expression*> interface,
|
||||
std::vector<Nonnull<AstNode*>> deduced_params,
|
||||
std::vector<Nonnull<Declaration*>> members)
|
||||
-> ErrorOr<Nonnull<ImplDeclaration*>> {
|
||||
std::vector<Nonnull<GenericBinding*>> resolved_params;
|
||||
for (Nonnull<AstNode*> param : deduced_params) {
|
||||
switch (param->kind()) {
|
||||
case AstNodeKind::GenericBinding:
|
||||
resolved_params.push_back(&cast<GenericBinding>(*param));
|
||||
break;
|
||||
default:
|
||||
return CompilationError(source_loc)
|
||||
<< "illegal AST node in implicit parameter list of impl";
|
||||
}
|
||||
}
|
||||
return arena->New<ImplDeclaration>(source_loc, kind, impl_type, interface,
|
||||
resolved_params, members);
|
||||
}
|
||||
|
||||
void AlternativeSignature::Print(llvm::raw_ostream& out) const {
|
||||
out << "alt " << name() << " " << signature();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user