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:
Richard Smith
2022-04-29 12:42:15 -07:00
committed by GitHub
parent b9538129a2
commit 3b58a1bf48
15 changed files with 513 additions and 197 deletions
+3 -2
View File
@@ -909,12 +909,13 @@ declaration:
$$ = arena->New<VariableDeclaration>(context.source_loc(), $2, $4,
ValueCategory::Let);
}
| INTERFACE identifier LEFT_CURLY_BRACE declaration_list RIGHT_CURLY_BRACE
| INTERFACE identifier type_params LEFT_CURLY_BRACE declaration_list RIGHT_CURLY_BRACE
{
auto ty_ty = arena -> New<TypeTypeLiteral>(context.source_loc());
auto self =
arena -> New<GenericBinding>(context.source_loc(), "Self", ty_ty);
$$ = arena->New<InterfaceDeclaration>(context.source_loc(), $2, self, $4);
$$ = arena->New<InterfaceDeclaration>(context.source_loc(), $2, $3, self,
$5);
}
| impl_kind IMPL impl_deduced_params expression AS expression LEFT_CURLY_BRACE declaration_list RIGHT_CURLY_BRACE
{