mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 09:21:04 +01:00
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:
@@ -238,6 +238,11 @@ static auto ApplyExtendImplAs(Context& context, SemIR::LocId loc_id,
|
||||
if (!impl.generic_id.has_value()) {
|
||||
parent_scope.AddExtendedScope(impl.constraint_id);
|
||||
} else {
|
||||
// The extended scope instruction must be part of the enclosing scope (and
|
||||
// generic). A specific for the enclosing scope will be applied to it when
|
||||
// using the instruction later. To do so, we wrap the constraint facet type
|
||||
// it in a SpecificConstant, which preserves the impl declaration's
|
||||
// specific along with the facet type.
|
||||
auto constraint_id_in_self_specific = AddTypeInst<SemIR::SpecificConstant>(
|
||||
context, SemIR::LocId(impl.constraint_id),
|
||||
{.type_id = SemIR::TypeType::TypeId,
|
||||
|
||||
Reference in New Issue
Block a user