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
+15
View File
@@ -301,6 +301,21 @@ auto HandleParseNode(Context& context, Parse::RequireDeclId node_id) -> bool {
})) {
return true;
}
// 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 require declaration's
// specific along with the facet type.
auto constraint_id_in_self_specific = AddTypeInst<SemIR::SpecificConstant>(
context, node_id,
{.type_id = SemIR::TypeType::TypeId,
.inst_id = constraint_inst_id,
.specific_id = context.generics().GetSelfSpecific(
context.require_impls().Get(require_impls_id).generic_id)});
auto enclosing_scope_id = context.scope_stack().PeekNameScopeId();
auto& enclosing_scope = context.name_scopes().Get(enclosing_scope_id);
enclosing_scope.AddExtendedScope(constraint_id_in_self_specific);
}
context.require_impls_stack().AppendToTop(require_impls_id);
+5
View File
@@ -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,
-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,
+10 -5
View File
@@ -328,11 +328,16 @@ auto AppendLookupScopesForConstant(Context& context, SemIR::LocId loc_id,
auto facet_type_info =
context.facet_types().Get(facet_type->facet_type_id);
// Name lookup into "extend" constraints but not "self impls" constraints.
// TODO: Include named constraints, once they are supported.
for (const auto& interface : facet_type_info.extend_constraints) {
auto& interface_info = context.interfaces().Get(interface.interface_id);
scopes->push_back({.name_scope_id = interface_info.scope_id,
.specific_id = interface.specific_id});
for (const auto& extend : facet_type_info.extend_constraints) {
auto& interface = context.interfaces().Get(extend.interface_id);
scopes->push_back({.name_scope_id = interface.scope_id,
.specific_id = extend.specific_id});
}
for (const auto& extend : facet_type_info.extend_named_constraints) {
auto& constraint =
context.named_constraints().Get(extend.named_constraint_id);
scopes->push_back({.name_scope_id = constraint.scope_id,
.specific_id = extend.specific_id});
}
} else {
// Lookup into this scope should fail without producing an error since
+2
View File
@@ -58,6 +58,7 @@ fn F(A:! X, B:! Y) {}
// CHECK:STDOUT: %Main.import_ref.926bc7.1: type = import_ref Main//a, loc10_24, loaded [concrete = constants.%Z.type]
// CHECK:STDOUT: %Main.import_ref.e33: %X.type = import_ref Main//a, loc9_14, loaded [symbolic = constants.%Self.f45]
// CHECK:STDOUT: %Main.import_ref.65b = import_ref Main//a, loc9_14, unloaded
// CHECK:STDOUT: %Main.import_ref.1c5 = import_ref Main//a, loc10_25, unloaded
// CHECK:STDOUT: %Main.import_ref.7bb: type = import_ref Main//a, loc6_11, loaded [symbolic = @Y.Self.binding.as_type.impls.Z.type.require.%Self.binding.as_type (constants.%Self.binding.as_type.63e)]
// CHECK:STDOUT: %Main.import_ref.926bc7.2: type = import_ref Main//a, loc6_17, loaded [concrete = constants.%Z.type]
// CHECK:STDOUT: %Main.import_ref.8c7: %Y.type = import_ref Main//a, loc5_13, loaded [symbolic = constants.%Self.d4d]
@@ -112,6 +113,7 @@ fn F(A:! X, B:! Y) {}
// CHECK:STDOUT: constraint @X [from "a.carbon"] {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%Main.import_ref.65b
// CHECK:STDOUT: extend imports.%Main.import_ref.1c5
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @X.Self.binding.as_type.impls.Z.type.require {
+20
View File
@@ -260,11 +260,13 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %T.ref: type = name_ref T, @J.%T.loc4_13.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %I.type.loc5_27.1: type = facet_type <@I, @I(constants.%T)> [symbolic = %I.type.loc5_27.2 (constants.%I.type.1ab)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc5: type = specific_constant @J.Self.binding.as_type.impls.I.type.require.%I.type.loc5_27.1, @J.Self.binding.as_type.impls.I.type.require(constants.%T, constants.%Self.a60) [symbolic = %I.type (constants.%I.type.1ab)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.loc4_23.1
// CHECK:STDOUT: .I = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: extend %.loc5
// CHECK:STDOUT: witness = ()
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
@@ -341,6 +343,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %Main.import_ref.b3bc94.2: type = import_ref Main//basic_import_generic_interface, loc4_13, loaded [symbolic = @J.%T (constants.%T)]
// CHECK:STDOUT: %Main.import_ref.99f: @J.%J.type (%J.type.04e) = import_ref Main//basic_import_generic_interface, loc4_23, loaded [symbolic = @J.%Self (constants.%Self.c25)]
// CHECK:STDOUT: %Main.import_ref.e9b = import_ref Main//basic_import_generic_interface, loc4_23, unloaded
// CHECK:STDOUT: %Main.import_ref.b55 = import_ref Main//basic_import_generic_interface, loc5_28, unloaded
// CHECK:STDOUT: %Main.import_ref.b3bc94.3: type = import_ref Main//basic_import_generic_interface, loc4_13, loaded [symbolic = @J.%T (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -397,6 +400,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: interface {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%Main.import_ref.e9b
// CHECK:STDOUT: extend imports.%Main.import_ref.b55
// CHECK:STDOUT: witness = ()
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
@@ -559,11 +563,13 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %T.ref: type = name_ref T, @J.%T.loc4_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %I.type.loc5_27.1: type = facet_type <@I, @I(constants.%T)> [symbolic = %I.type.loc5_27.2 (constants.%I.type.1ab)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc5: type = specific_constant @J.Self.binding.as_type.impls.I.type.require.%I.type.loc5_27.1, @J.Self.binding.as_type.impls.I.type.require(constants.%T, constants.%Self.31c) [symbolic = %I.type (constants.%I.type.1ab)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.loc4_24.1
// CHECK:STDOUT: .I = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: extend %.loc5
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @J.Self.binding.as_type.impls.I.type.require {
@@ -636,6 +642,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %Main.import_ref.b3bc94.2: type = import_ref Main//basic_import_generic_constraint, loc4_14, loaded [symbolic = @J.%T (constants.%T)]
// CHECK:STDOUT: %Main.import_ref.2fc: @J.%J.type (%J.type.d682d6.1) = import_ref Main//basic_import_generic_constraint, loc4_24, loaded [symbolic = @J.%Self (constants.%Self.e1f642.1)]
// CHECK:STDOUT: %Main.import_ref.830 = import_ref Main//basic_import_generic_constraint, loc4_24, unloaded
// CHECK:STDOUT: %Main.import_ref.b41 = import_ref Main//basic_import_generic_constraint, loc5_28, unloaded
// CHECK:STDOUT: %Main.import_ref.b3bc94.3: type = import_ref Main//basic_import_generic_constraint, loc4_14, loaded [symbolic = @J.%T (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -685,6 +692,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: constraint {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%Main.import_ref.830
// CHECK:STDOUT: extend imports.%Main.import_ref.b41
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @J.Self.binding.as_type.impls.I.type.require {
@@ -880,11 +888,13 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %T.ref: type = name_ref T, @N.%T.loc14_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %I.type.loc15_27.1: type = facet_type <@I, @I(constants.%T)> [symbolic = %I.type.loc15_27.2 (constants.%I.type.1ab)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc15: type = specific_constant @N.Self.binding.as_type.impls.I.type.require.%I.type.loc15_27.1, @N.Self.binding.as_type.impls.I.type.require(constants.%T, constants.%Self.31c) [symbolic = %I.type (constants.%I.type.1ab)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.loc14_24.1
// CHECK:STDOUT: .I = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: extend %.loc15
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @N.Self.binding.as_type.impls.I.type.require {
@@ -1038,6 +1048,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %Main.import_ref.b3bc94.4: type = import_ref Main//import_generic, loc14_14, loaded [symbolic = @N.%T (constants.%T)]
// CHECK:STDOUT: %Main.import_ref.2fc: @N.%N.type (%N.type.d682d6.1) = import_ref Main//import_generic, loc14_24, loaded [symbolic = @N.%Self (constants.%Self.e1f)]
// CHECK:STDOUT: %Main.import_ref.830 = import_ref Main//import_generic, loc14_24, unloaded
// CHECK:STDOUT: %Main.import_ref.b41 = import_ref Main//import_generic, loc15_28, unloaded
// CHECK:STDOUT: %Main.import_ref.b3bc94.5: type = import_ref Main//import_generic, loc14_14, loaded [symbolic = @N.%T (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1142,6 +1153,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: constraint {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%Main.import_ref.830
// CHECK:STDOUT: extend imports.%Main.import_ref.b41
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @N.Self.binding.as_type.impls.I.type.require {
@@ -1434,11 +1446,13 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %T.ref: type = name_ref T, @N.%T.loc9_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %I.type.loc10_27.1: type = facet_type <@I, @I(constants.%T)> [symbolic = %I.type.loc10_27.2 (constants.%I.type.1ab)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc10: type = specific_constant @N.Self.binding.as_type.impls.I.type.require.%I.type.loc10_27.1, @N.Self.binding.as_type.impls.I.type.require(constants.%T, constants.%Self.31c) [symbolic = %I.type (constants.%I.type.1ab)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.loc9_24.1
// CHECK:STDOUT: .I = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: extend %.loc10
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @N.Self.binding.as_type.impls.I.type.require {
@@ -1560,6 +1574,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %Main.import_ref.b3bc94.3: type = import_ref Main//import_generic_with_different_specific, loc9_14, loaded [symbolic = @N.%T (constants.%T)]
// CHECK:STDOUT: %Main.import_ref.2fc: @N.%N.type (%N.type.d682d6.1) = import_ref Main//import_generic_with_different_specific, loc9_24, loaded [symbolic = @N.%Self (constants.%Self.e1f642.1)]
// CHECK:STDOUT: %Main.import_ref.830 = import_ref Main//import_generic_with_different_specific, loc9_24, unloaded
// CHECK:STDOUT: %Main.import_ref.b41 = import_ref Main//import_generic_with_different_specific, loc10_28, unloaded
// CHECK:STDOUT: %Main.import_ref.b3bc94.4: type = import_ref Main//import_generic_with_different_specific, loc9_14, loaded [symbolic = @N.%T (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -1624,6 +1639,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: constraint {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%Main.import_ref.830
// CHECK:STDOUT: extend imports.%Main.import_ref.b41
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @N.Self.binding.as_type.impls.I.type.require {
@@ -1874,11 +1890,13 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %T.ref: type = name_ref T, @N.%T.loc7_14.2 [symbolic = %T (constants.%T)]
// CHECK:STDOUT: %J.type.loc8_27.1: type = facet_type <@J, @J(constants.%T)> [symbolic = %J.type.loc8_27.2 (constants.%J.type.04e)]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc8: type = specific_constant @N.Self.binding.as_type.impls.J.type.require.%J.type.loc8_27.1, @N.Self.binding.as_type.impls.J.type.require(constants.%T, constants.%Self.31c) [symbolic = %J.type (constants.%J.type.04e)]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self.loc7_24.1
// CHECK:STDOUT: .J = <poisoned>
// CHECK:STDOUT: .T = <poisoned>
// CHECK:STDOUT: extend %.loc8
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @N.Self.binding.as_type.impls.J.type.require {
@@ -2006,6 +2024,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: %Main.import_ref.b3bc94.4: type = import_ref Main//import_generic_decl, loc7_14, loaded [symbolic = @N.%T (constants.%T)]
// CHECK:STDOUT: %Main.import_ref.2fc: @N.%N.type (%N.type.d682d6.1) = import_ref Main//import_generic_decl, loc7_24, loaded [symbolic = @N.%Self (constants.%Self.e1f)]
// CHECK:STDOUT: %Main.import_ref.830 = import_ref Main//import_generic_decl, loc7_24, unloaded
// CHECK:STDOUT: %Main.import_ref.105 = import_ref Main//import_generic_decl, loc8_28, unloaded
// CHECK:STDOUT: %Main.import_ref.b3bc94.5: type = import_ref Main//import_generic_decl, loc7_14, loaded [symbolic = @N.%T (constants.%T)]
// CHECK:STDOUT: }
// CHECK:STDOUT:
@@ -2110,6 +2129,7 @@ impl forall [T:! type] D as N(T*) {}
// CHECK:STDOUT: constraint {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%Main.import_ref.830
// CHECK:STDOUT: extend imports.%Main.import_ref.105
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @N.Self.binding.as_type.impls.J.type.require {
+14 -2
View File
@@ -23,8 +23,12 @@ interface Z {
}
//@dump-sem-ir-end
fn F(T:! Z) {
// CHECK:STDERR: fail_todo_extend.carbon:[[@LINE+4]]:3: error: member name `YY` not found in `Z` [MemberNameNotFoundInInstScope]
fn F(T:! Z, t:! T) {
// TODO: We find the name `YY`, but then fail to do impl lookup for `Y` in
// `T:! Z` since the identified facet type doesn't include `Y`. The
// identified facet type needs to include extends inside interfaces?
// CHECK:STDERR: fail_todo_extend.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Y` in type `T` that does not implement that interface [MissingImplInMemberAccess]
// CHECK:STDERR: T.YY();
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
@@ -34,6 +38,12 @@ fn F(T:! Z) {
// CHECK:STDERR: ^~~~~~~~
// CHECK:STDERR:
T.(Y.YY)();
// CHECK:STDERR: fail_todo_extend.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Y` in type `T` that does not implement that interface [MissingImplInMemberAccess]
// CHECK:STDERR: t.YY();
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
t.YY();
}
// --- fail_todo_implicit_self_impls.carbon
@@ -293,11 +303,13 @@ interface Z(T:! type) {
// CHECK:STDOUT: %Self.as_type: type = facet_access_type @Z.%Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
// CHECK:STDOUT: %Y.ref: type = name_ref Y, file.%Y.decl [concrete = constants.%Y.type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc9: type = specific_constant @Z.Self.binding.as_type.impls.Y.type.require.%Y.ref, @Z.Self.binding.as_type.impls.Y.type.require(constants.%Self.c59) [concrete = constants.%Y.type]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self
// CHECK:STDOUT: .Y = <poisoned>
// CHECK:STDOUT: .YY = <poisoned>
// CHECK:STDOUT: extend %.loc9
// CHECK:STDOUT: witness = ()
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
@@ -99,6 +99,7 @@ impl C as B {}
// CHECK:STDOUT: %Main.import_ref.72a: type = import_ref Main//b, loc5_24, loaded [concrete = constants.%I.type]
// CHECK:STDOUT: %Main.import_ref.e33: %B.type = import_ref Main//b, loc4_14, loaded [symbolic = constants.%Self.f45]
// CHECK:STDOUT: %Main.import_ref.65b = import_ref Main//b, loc4_14, unloaded
// CHECK:STDOUT: %Main.import_ref.121 = import_ref Main//b, loc5_25, unloaded
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: file {
@@ -131,6 +132,7 @@ impl C as B {}
// CHECK:STDOUT: constraint @B [from "b.carbon"] {
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = imports.%Main.import_ref.65b
// CHECK:STDOUT: extend imports.%Main.import_ref.121
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @B.Self.binding.as_type.impls.I.type.require {
+66 -9
View File
@@ -10,7 +10,7 @@
// TIP: To dump output, run:
// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/named_constraint/require.carbon
// --- fail_todo_extend.carbon
// --- extend.carbon
library "[[@TEST_NAME]]";
interface Y {
@@ -23,13 +23,13 @@ constraint Z {
}
//@dump-sem-ir-end
fn F(T:! Z) {
// CHECK:STDERR: fail_todo_extend.carbon:[[@LINE+4]]:3: error: member name `YY` not found [MemberNameNotFound]
// CHECK:STDERR: T.YY();
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
fn F(T:! Z, t: T) {
//@dump-sem-ir-begin
T.YY();
T.(Y.YY)();
t.YY();
//@dump-sem-ir-end
}
// --- implicit_self_impls.carbon
@@ -80,7 +80,7 @@ constraint Z {
fn F(T:! Z) {
// This should fail name lookup since Z does not extend Y.
//
// CHECK:STDERR: fail_implicit_self_no_extend_name_lookup_fails.carbon:[[@LINE+4]]:3: error: member name `YY` not found [MemberNameNotFound]
// CHECK:STDERR: fail_implicit_self_no_extend_name_lookup_fails.carbon:[[@LINE+4]]:3: error: member name `YY` not found in `Z` [MemberNameNotFoundInInstScope]
// CHECK:STDERR: T.YY();
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
@@ -101,7 +101,7 @@ constraint Z {
fn F(T:! Z) {
// This should fail name lookup since Z does not extend Y.
//
// CHECK:STDERR: fail_explicit_self_no_extend_name_lookup_fails.carbon:[[@LINE+4]]:3: error: member name `YY` not found [MemberNameNotFound]
// CHECK:STDERR: fail_explicit_self_no_extend_name_lookup_fails.carbon:[[@LINE+4]]:3: error: member name `YY` not found in `Z` [MemberNameNotFoundInInstScope]
// CHECK:STDERR: T.YY();
// CHECK:STDERR: ^~~~
// CHECK:STDERR:
@@ -419,15 +419,25 @@ fn F() {
() as N;
}
// CHECK:STDOUT: --- fail_todo_extend.carbon
// CHECK:STDOUT: --- extend.carbon
// CHECK:STDOUT:
// CHECK:STDOUT: constants {
// CHECK:STDOUT: %Y.type: type = facet_type <@Y> [concrete]
// CHECK:STDOUT: %Y.YY.type: type = fn_type @Y.YY [concrete]
// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
// CHECK:STDOUT: %Y.assoc_type: type = assoc_entity_type @Y [concrete]
// CHECK:STDOUT: %assoc0: %Y.assoc_type = assoc_entity element0, @Y.%Y.YY.decl [concrete]
// CHECK:STDOUT: %Z.type: type = facet_type <@Z> [concrete]
// CHECK:STDOUT: %Self.550: %Z.type = symbolic_binding Self, 0 [symbolic]
// CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self.550 [symbolic]
// CHECK:STDOUT: %T: %Z.type = symbolic_binding T, 0 [symbolic]
// CHECK:STDOUT: %T.binding.as_type: type = symbolic_binding_type T, 0, %T [symbolic]
// CHECK:STDOUT: %pattern_type.349: type = pattern_type %T.binding.as_type [symbolic]
// CHECK:STDOUT: %Y.lookup_impl_witness: <witness> = lookup_impl_witness %T, @Y [symbolic]
// CHECK:STDOUT: %Y.facet: %Y.type = facet_value %T.binding.as_type, (%Y.lookup_impl_witness) [symbolic]
// CHECK:STDOUT: %.bb4: type = fn_type_with_self_type %Y.YY.type, %Y.facet [symbolic]
// CHECK:STDOUT: %impl.elem0: %.bb4 = impl_witness_access %Y.lookup_impl_witness, element0 [symbolic]
// CHECK:STDOUT: %specific_impl_fn: <specific function> = specific_impl_function %impl.elem0, @Y.YY(%Y.facet) [symbolic]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: imports {
@@ -445,10 +455,13 @@ fn F() {
// CHECK:STDOUT: %Self.as_type: type = facet_access_type @Z.%Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
// CHECK:STDOUT: %Y.ref: type = name_ref Y, file.%Y.decl [concrete = constants.%Y.type]
// CHECK:STDOUT: }
// CHECK:STDOUT: %.loc9: type = specific_constant @Z.Self.binding.as_type.impls.Y.type.require.%Y.ref, @Z.Self.binding.as_type.impls.Y.type.require(constants.%Self.550) [concrete = constants.%Y.type]
// CHECK:STDOUT:
// CHECK:STDOUT: !members:
// CHECK:STDOUT: .Self = %Self
// CHECK:STDOUT: .Y = <poisoned>
// CHECK:STDOUT: .YY = <poisoned>
// CHECK:STDOUT: extend %.loc9
// CHECK:STDOUT:
// CHECK:STDOUT: !requires:
// CHECK:STDOUT: @Z.Self.binding.as_type.impls.Y.type.require {
@@ -461,11 +474,55 @@ fn F() {
// CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: generic fn @F(%T.loc13_6.2: %Z.type) {
// CHECK:STDOUT: <elided>
// CHECK:STDOUT:
// CHECK:STDOUT: !definition:
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: %Y.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc13_6.1, @Y [symbolic = %Y.lookup_impl_witness (constants.%Y.lookup_impl_witness)]
// CHECK:STDOUT: %Y.facet.loc15: %Y.type = facet_value %T.binding.as_type, (%Y.lookup_impl_witness) [symbolic = %Y.facet.loc15 (constants.%Y.facet)]
// CHECK:STDOUT: %.loc15_4.2: type = fn_type_with_self_type constants.%Y.YY.type, %Y.facet.loc15 [symbolic = %.loc15_4.2 (constants.%.bb4)]
// CHECK:STDOUT: %impl.elem0.loc15_4.2: @F.%.loc15_4.2 (%.bb4) = impl_witness_access %Y.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_4.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc15_4.2: <specific function> = specific_impl_function %impl.elem0.loc15_4.2, @Y.YY(%Y.facet.loc15) [symbolic = %specific_impl_fn.loc15_4.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT:
// CHECK:STDOUT: fn(%t.param: @F.%T.binding.as_type (%T.binding.as_type)) {
// CHECK:STDOUT: !entry:
// CHECK:STDOUT: %T.ref.loc15: %Z.type = name_ref T, %T.loc13_6.2 [symbolic = %T.loc13_6.1 (constants.%T)]
// CHECK:STDOUT: %T.as_type.loc15: type = facet_access_type %T.ref.loc15 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
// CHECK:STDOUT: %.loc15_4.1: type = converted %T.ref.loc15, %T.as_type.loc15 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
// CHECK:STDOUT: %YY.ref.loc15: %Y.assoc_type = name_ref YY, @Y.%assoc0 [concrete = constants.%assoc0]
// CHECK:STDOUT: %impl.elem0.loc15_4.1: @F.%.loc15_4.2 (%.bb4) = impl_witness_access constants.%Y.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_4.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc15_4.1: <specific function> = specific_impl_function %impl.elem0.loc15_4.1, @Y.YY(constants.%Y.facet) [symbolic = %specific_impl_fn.loc15_4.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %Y.YY.call.loc15: init %empty_tuple.type = call %specific_impl_fn.loc15_4.1()
// CHECK:STDOUT: %T.ref.loc16: %Z.type = name_ref T, %T.loc13_6.2 [symbolic = %T.loc13_6.1 (constants.%T)]
// CHECK:STDOUT: %Y.ref: type = name_ref Y, file.%Y.decl [concrete = constants.%Y.type]
// CHECK:STDOUT: %YY.ref.loc16: %Y.assoc_type = name_ref YY, @Y.%assoc0 [concrete = constants.%assoc0]
// CHECK:STDOUT: %T.as_type.loc16: type = facet_access_type %T.ref.loc16 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
// CHECK:STDOUT: %Y.facet.loc16: %Y.type = facet_value %T.as_type.loc16, (constants.%Y.lookup_impl_witness) [symbolic = %Y.facet.loc15 (constants.%Y.facet)]
// CHECK:STDOUT: %.loc16: %Y.type = converted %T.ref.loc16, %Y.facet.loc16 [symbolic = %Y.facet.loc15 (constants.%Y.facet)]
// CHECK:STDOUT: %impl.elem0.loc16: @F.%.loc15_4.2 (%.bb4) = impl_witness_access constants.%Y.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_4.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc16: <specific function> = specific_impl_function %impl.elem0.loc16, @Y.YY(constants.%Y.facet) [symbolic = %specific_impl_fn.loc15_4.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %Y.YY.call.loc16: init %empty_tuple.type = call %specific_impl_fn.loc16()
// CHECK:STDOUT: %t.ref: @F.%T.binding.as_type (%T.binding.as_type) = name_ref t, %t
// CHECK:STDOUT: %YY.ref.loc18: %Y.assoc_type = name_ref YY, @Y.%assoc0 [concrete = constants.%assoc0]
// CHECK:STDOUT: %impl.elem0.loc18: @F.%.loc15_4.2 (%.bb4) = impl_witness_access constants.%Y.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc15_4.2 (constants.%impl.elem0)]
// CHECK:STDOUT: %specific_impl_fn.loc18: <specific function> = specific_impl_function %impl.elem0.loc18, @Y.YY(constants.%Y.facet) [symbolic = %specific_impl_fn.loc15_4.2 (constants.%specific_impl_fn)]
// CHECK:STDOUT: %Y.YY.call.loc18: init %empty_tuple.type = call %specific_impl_fn.loc18()
// CHECK:STDOUT: <elided>
// CHECK:STDOUT: }
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Z.Self.binding.as_type.impls.Y.type.require(constants.%Self.550) {
// CHECK:STDOUT: %Self => constants.%Self.550
// CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @F(constants.%T) {
// CHECK:STDOUT: %T.loc13_6.1 => constants.%T
// CHECK:STDOUT: %T.binding.as_type => constants.%T.binding.as_type
// CHECK:STDOUT: %pattern_type => constants.%pattern_type.349
// CHECK:STDOUT: }
// CHECK:STDOUT:
// CHECK:STDOUT: specific @Z.Self.binding.as_type.impls.Y.type.require(constants.%T) {
// CHECK:STDOUT: %Self => constants.%T
// CHECK:STDOUT: %Self.binding.as_type => constants.%T.binding.as_type