Handle parsing of require...impls declarations (#6255)

Check is not implemented yet, but some tests are added.
This commit is contained in:
Dana Jansens
2025-10-23 18:34:52 +00:00
committed by GitHub
parent 4f1f0fc7c2
commit 26381f6eaf
30 changed files with 790 additions and 61 deletions
+2 -2
View File
@@ -433,7 +433,7 @@ static auto ExtendImpl(Context& context, Parse::NodeId extend_node,
const auto& impl = context.impls().Get(impl_id);
if (context.parse_tree().node_kind(self_type_node_id) ==
Parse::NodeKind::TypeImplAs) {
Parse::NodeKind::ImplTypeAs) {
CARBON_DIAGNOSTIC(ExtendImplSelfAs, Error,
"cannot `extend` an `impl` with an explicit self type");
auto diag = context.emitter().Build(extend_node, ExtendImplSelfAs);
@@ -448,7 +448,7 @@ static auto ExtendImpl(Context& context, Parse::NodeId extend_node,
// The explicit self type is the same as the default self type, so suggest
// removing it and recover as if it were not present.
if (auto self_as =
context.parse_tree_and_subtrees().ExtractAs<Parse::TypeImplAs>(
context.parse_tree_and_subtrees().ExtractAs<Parse::ImplTypeAs>(
self_type_node_id)) {
CARBON_DIAGNOSTIC(ExtendImplSelfAsDefault, Note,
"remove the explicit `Self` type here");