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:
Jeremy G. Siek
2022-04-20 10:18:01 -04:00
committed by GitHub
parent 958fb8e529
commit b784458aef
20 changed files with 893 additions and 386 deletions
+21
View File
@@ -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();
}