Look through extend require in an interface or named constraint in name lookup (#6630)

Add the required facet type as an extended scope of the containing
interface/named constraint, and teach name lookup to look for extended
scopes in named constraints.

This makes name lookup work properly when the facet type does not have a
specific that involves `Self`. Support for `Self` needs further work in
another PR.

Note that when an _interface_ requires another interface, this PR lets
us find the name, but we still fail to find a witness for the interface
named through `extend require`, and this is future work. For a named
constraint, things work correctly as the identified facet type chases
through the named constraint and includes the required interface, so
impl lookup is able to provide a witness.
This commit is contained in:
Dana Jansens
2026-01-20 22:26:10 +00:00
committed by GitHub
parent c0e7198995
commit 4bb2935770
9 changed files with 134 additions and 23 deletions
-7
View File
@@ -2779,9 +2779,6 @@ static auto AddInterfaceDefinition(ImportContext& context,
new_interface.body_block_id =
context.local_context().inst_block_stack().Pop();
new_interface.self_param_id = self_param_id;
CARBON_CHECK(import_scope.extended_scopes().empty(),
"Interfaces don't currently have extended scopes to support.");
}
static auto TryResolveTypedInst(ImportRefResolver& resolver,
@@ -2930,10 +2927,6 @@ static auto AddNamedConstraintDefinition(
context.local_context().inst_block_stack().Pop();
new_named_constraint.self_param_id = self_param_id;
new_named_constraint.complete = import_named_constraint.complete;
CARBON_CHECK(
import_scope.extended_scopes().empty(),
"Named constraints don't currently have extended scopes to support.");
}
static auto TryResolveTypedInst(ImportRefResolver& resolver,