From 9ec3e750357a889f6f2baae7a8f7e233deda8df7 Mon Sep 17 00:00:00 2001 From: Josh L Date: Mon, 11 Nov 2024 23:48:50 +0000 Subject: [PATCH 1/3] Checkpoint progress. --- toolchain/check/impl_lookup.cpp | 10 +- .../impl/lookup/no_prelude/import.carbon | 666 +++++++++++++++--- 2 files changed, 561 insertions(+), 115 deletions(-) diff --git a/toolchain/check/impl_lookup.cpp b/toolchain/check/impl_lookup.cpp index be0c0ea6edccc..8f7f49f2cc048 100644 --- a/toolchain/check/impl_lookup.cpp +++ b/toolchain/check/impl_lookup.cpp @@ -62,8 +62,12 @@ static auto FindAssociatedImportIRs(Context& context, add_entity(context.classes().Get(SemIR::ClassId(arg))); break; } - case SemIR::IdKind::For: { - add_entity(context.interfaces().Get(SemIR::InterfaceId(arg))); + case SemIR::IdKind::For: { + const auto& facet_type_info = + context.sem_ir().facet_types().Get(SemIR::FacetTypeId(arg)); + for (const auto& impl : facet_type_info.impls_constraints) { + add_entity(context.interfaces().Get(impl.interface_id)); + } break; } case SemIR::IdKind::For: { @@ -71,6 +75,8 @@ static auto FindAssociatedImportIRs(Context& context, break; } default: { + // FIXME: delete + CARBON_CHECK(kind != SemIR::IdKind::For); break; } } diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon index ba33094d1155e..3406f8e4f6706 100644 --- a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon +++ b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon @@ -50,27 +50,71 @@ impl D as HasG { fn G() {} } -// --- use.carbon +// --- use_cf.carbon + +library "[[@TEST_NAME]]"; import PackageA; -import PackageB; fn TestCF(c: PackageA.C) { c.(PackageA.HasF.F)(); } +// --- use_df.carbon + +library "[[@TEST_NAME]]"; + +import PackageA; +import PackageB; + fn TestDF(d: PackageB.D) { d.(PackageA.HasF.F)(); } + +// --- use_cg.carbon + +library "[[@TEST_NAME]]"; + +import PackageA; +import PackageB; + fn TestCG(c: PackageA.C) { c.(PackageB.HasG.G)(); } +// --- use_dg.carbon + +library "[[@TEST_NAME]]"; + +import PackageB; + fn TestDG(d: PackageB.D) { d.(PackageB.HasG.G)(); } +// --- package_foo.carbon + +package PackageFoo; + +interface A { + fn F(); +} + +impl () as A { + fn F() {} +} + +// --- use_package_foo.carbon + +library "[[@TEST_NAME]]"; + +import PackageFoo; + +fn G() { + ().(PackageFoo.A.F)(); +} + // CHECK:STDOUT: --- package_a.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { @@ -303,7 +347,7 @@ fn TestDG(d: PackageB.D) { // CHECK:STDOUT: // CHECK:STDOUT: specific @G.1(constants.%D) {} // CHECK:STDOUT: -// CHECK:STDOUT: --- use.carbon +// CHECK:STDOUT: --- use_cf.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %C: type = class_type @C [template] @@ -314,7 +358,7 @@ fn TestDG(d: PackageB.D) { // CHECK:STDOUT: %TestCF: %TestCF.type = struct_value () [template] // CHECK:STDOUT: %.3: type = ptr_type %.1 [template] // CHECK:STDOUT: %HasF.type: type = facet_type <@HasF> [template] -// CHECK:STDOUT: %Self.1: %HasF.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %Self: %HasF.type = bind_symbolic_name Self, 0 [symbolic] // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] // CHECK:STDOUT: %.4: type = assoc_entity_type %HasF.type, %F.type.1 [template] @@ -322,28 +366,6 @@ fn TestDG(d: PackageB.D) { // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: %.6: = interface_witness (%F.2) [template] -// CHECK:STDOUT: %D: type = class_type @D [template] -// CHECK:STDOUT: %TestDF.type: type = fn_type @TestDF [template] -// CHECK:STDOUT: %TestDF: %TestDF.type = struct_value () [template] -// CHECK:STDOUT: %HasG.type: type = facet_type <@HasG> [template] -// CHECK:STDOUT: %Self.2: %HasG.type = bind_symbolic_name Self, 0 [symbolic] -// CHECK:STDOUT: %F.type.3: type = fn_type @F.3 [template] -// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] -// CHECK:STDOUT: %.7: = interface_witness (%F.3) [template] -// CHECK:STDOUT: %TestCG.type: type = fn_type @TestCG [template] -// CHECK:STDOUT: %TestCG: %TestCG.type = struct_value () [template] -// CHECK:STDOUT: %G.type.1: type = fn_type @G.1 [template] -// CHECK:STDOUT: %G.1: %G.type.1 = struct_value () [template] -// CHECK:STDOUT: %.8: type = assoc_entity_type %HasG.type, %G.type.1 [template] -// CHECK:STDOUT: %.9: %.8 = assoc_entity element0, imports.%import_ref.26 [template] -// CHECK:STDOUT: %G.type.2: type = fn_type @G.2 [template] -// CHECK:STDOUT: %G.2: %G.type.2 = struct_value () [template] -// CHECK:STDOUT: %.10: = interface_witness (%G.2) [template] -// CHECK:STDOUT: %TestDG.type: type = fn_type @TestDG [template] -// CHECK:STDOUT: %TestDG: %TestDG.type = struct_value () [template] -// CHECK:STDOUT: %G.type.3: type = fn_type @G.3 [template] -// CHECK:STDOUT: %G.3: %G.type.3 = struct_value () [template] -// CHECK:STDOUT: %.11: = interface_witness (%G.3) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -352,11 +374,6 @@ fn TestDG(d: PackageB.D) { // CHECK:STDOUT: .HasF = %import_ref.3 // CHECK:STDOUT: import PackageA//default // CHECK:STDOUT: } -// CHECK:STDOUT: %PackageB: = namespace file.%PackageB.import, [template] { -// CHECK:STDOUT: .D = %import_ref.11 -// CHECK:STDOUT: .HasG = %import_ref.25 -// CHECK:STDOUT: import PackageB//default -// CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.1: type = import_ref PackageA//default, inst+12, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.2 = import_ref PackageA//default, inst+13, unloaded // CHECK:STDOUT: %import_ref.3: type = import_ref PackageA//default, inst+1, loaded [template = constants.%HasF.type] @@ -367,53 +384,269 @@ fn TestDG(d: PackageB.D) { // CHECK:STDOUT: %import_ref.8: type = import_ref PackageA//default, inst+17, loaded [template = constants.%C] // CHECK:STDOUT: %import_ref.9: type = import_ref PackageA//default, inst+18, loaded [template = constants.%HasF.type] // CHECK:STDOUT: %import_ref.10: = import_ref PackageA//default, inst+23, loaded [template = constants.%.6] -// CHECK:STDOUT: %import_ref.11: type = import_ref PackageB//default, inst+14, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.12 = import_ref PackageB//default, inst+15, unloaded -// CHECK:STDOUT: %import_ref.13 = import_ref PackageB//default, inst+5, unloaded -// CHECK:STDOUT: %import_ref.14: %.8 = import_ref PackageB//default, inst+12, loaded [template = constants.%.9] -// CHECK:STDOUT: %import_ref.15 = import_ref PackageB//default, inst+7, unloaded -// CHECK:STDOUT: %import_ref.16: type = import_ref PackageB//default, inst+24, loaded [template = constants.%C] -// CHECK:STDOUT: %import_ref.17: type = import_ref PackageB//default, inst+25, loaded [template = constants.%HasG.type] -// CHECK:STDOUT: %import_ref.18: = import_ref PackageB//default, inst+30, loaded [template = constants.%.10] -// CHECK:STDOUT: %import_ref.19: type = import_ref PackageB//default, inst+33, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.20: type = import_ref PackageB//default, inst+42, loaded [template = constants.%HasF.type] -// CHECK:STDOUT: %import_ref.21: = import_ref PackageB//default, inst+50, loaded [template = constants.%.7] -// CHECK:STDOUT: %import_ref.22: type = import_ref PackageB//default, inst+53, loaded [template = constants.%D] -// CHECK:STDOUT: %import_ref.23: type = import_ref PackageB//default, inst+54, loaded [template = constants.%HasG.type] -// CHECK:STDOUT: %import_ref.24: = import_ref PackageB//default, inst+59, loaded [template = constants.%.11] -// CHECK:STDOUT: %import_ref.25: type = import_ref PackageB//default, inst+3, loaded [template = constants.%HasG.type] -// CHECK:STDOUT: %import_ref.26 = import_ref PackageB//default, inst+7, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .PackageA = imports.%PackageA -// CHECK:STDOUT: .PackageB = imports.%PackageB // CHECK:STDOUT: .TestCF = %TestCF.decl -// CHECK:STDOUT: .TestDF = %TestDF.decl -// CHECK:STDOUT: .TestCG = %TestCG.decl -// CHECK:STDOUT: .TestDG = %TestDG.decl // CHECK:STDOUT: } // CHECK:STDOUT: %PackageA.import = import PackageA -// CHECK:STDOUT: %PackageB.import = import PackageB // CHECK:STDOUT: %TestCF.decl: %TestCF.type = fn_decl @TestCF [template = constants.%TestCF] { // CHECK:STDOUT: %c.patt: %C = binding_pattern c // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, runtime_param0 // CHECK:STDOUT: } { -// CHECK:STDOUT: %PackageA.ref.loc5: = name_ref PackageA, imports.%PackageA [template = imports.%PackageA] +// CHECK:STDOUT: %PackageA.ref.loc6: = name_ref PackageA, imports.%PackageA [template = imports.%PackageA] // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C] // CHECK:STDOUT: %c.param: %C = value_param runtime_param0 // CHECK:STDOUT: %c: %C = bind_name c, %c.param // CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @HasF { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .F = imports.%import_ref.5 +// CHECK:STDOUT: witness = (imports.%import_ref.6) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: imports.%import_ref.8 as imports.%import_ref.9 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.10 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @TestCF(%c.param_patt: %C) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %c.ref: %C = name_ref c, %c +// CHECK:STDOUT: %PackageA.ref.loc7: = name_ref PackageA, imports.%PackageA [template = imports.%PackageA] +// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.3 [template = constants.%HasF.type] +// CHECK:STDOUT: %F.ref: %.4 = name_ref F, imports.%import_ref.5 [template = constants.%.5] +// CHECK:STDOUT: %.loc7: %F.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%F.2] +// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc7() +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%Self: %HasF.type) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- use_df.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %D: type = class_type @D [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %TestDF.type: type = fn_type @TestDF [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %TestDF: %TestDF.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %HasF.type: type = facet_type <@HasF> [template] +// CHECK:STDOUT: %Self.1: %HasF.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] +// CHECK:STDOUT: %.4: type = assoc_entity_type %HasF.type, %F.type.1 [template] +// CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.7 [template] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %HasG.type: type = facet_type <@HasG> [template] +// CHECK:STDOUT: %Self.2: %HasG.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %.6: = interface_witness (%F.2) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %PackageA: = namespace file.%PackageA.import, [template] { +// CHECK:STDOUT: .HasF = %import_ref.3 +// CHECK:STDOUT: import PackageA//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageB: = namespace file.%PackageB.import, [template] { +// CHECK:STDOUT: .D = %import_ref.1 +// CHECK:STDOUT: import PackageB//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref PackageB//default, inst+14, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.2 = import_ref PackageB//default, inst+15, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref PackageA//default, inst+1, loaded [template = constants.%HasF.type] +// CHECK:STDOUT: %import_ref.4 = import_ref PackageA//default, inst+3, unloaded +// CHECK:STDOUT: %import_ref.5: %.4 = import_ref PackageA//default, inst+10, loaded [template = constants.%.5] +// CHECK:STDOUT: %import_ref.6 = import_ref PackageA//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref PackageA//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref PackageA//default, inst+13, unloaded +// CHECK:STDOUT: %import_ref.9: type = import_ref PackageA//default, inst+17, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.10: type = import_ref PackageA//default, inst+18, loaded [template = constants.%HasF.type] +// CHECK:STDOUT: %import_ref.11 = import_ref PackageA//default, inst+23, unloaded +// CHECK:STDOUT: %import_ref.12 = import_ref PackageB//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.13 = import_ref PackageB//default, inst+12, unloaded +// CHECK:STDOUT: %import_ref.14 = import_ref PackageB//default, inst+7, unloaded +// CHECK:STDOUT: %import_ref.15: type = import_ref PackageB//default, inst+24, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.16: type = import_ref PackageB//default, inst+25, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.17 = import_ref PackageB//default, inst+30, unloaded +// CHECK:STDOUT: %import_ref.18: type = import_ref PackageB//default, inst+33, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.19: type = import_ref PackageB//default, inst+42, loaded [template = constants.%HasF.type] +// CHECK:STDOUT: %import_ref.20: = import_ref PackageB//default, inst+50, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.21: type = import_ref PackageB//default, inst+53, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.22: type = import_ref PackageB//default, inst+54, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.23 = import_ref PackageB//default, inst+59, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .PackageA = imports.%PackageA +// CHECK:STDOUT: .PackageB = imports.%PackageB +// CHECK:STDOUT: .TestDF = %TestDF.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageA.import = import PackageA +// CHECK:STDOUT: %PackageB.import = import PackageB // CHECK:STDOUT: %TestDF.decl: %TestDF.type = fn_decl @TestDF [template = constants.%TestDF] { // CHECK:STDOUT: %d.patt: %D = binding_pattern d // CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %PackageB.ref: = name_ref PackageB, imports.%PackageB [template = imports.%PackageB] -// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.11 [template = constants.%D] +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.1 [template = constants.%D] // CHECK:STDOUT: %d.param: %D = value_param runtime_param0 // CHECK:STDOUT: %d: %D = bind_name d, %d.param // CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @HasF { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .F = imports.%import_ref.5 +// CHECK:STDOUT: witness = (imports.%import_ref.6) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @HasG { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.12 +// CHECK:STDOUT: .G = imports.%import_ref.13 +// CHECK:STDOUT: witness = (imports.%import_ref.14) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.1: imports.%import_ref.9 as imports.%import_ref.10 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.11 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.2: imports.%import_ref.15 as imports.%import_ref.16 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.17 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.3: imports.%import_ref.18 as imports.%import_ref.19 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.20 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.4: imports.%import_ref.21 as imports.%import_ref.22 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.23 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @D { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.8 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @TestDF(%d.param_patt: %D) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %d.ref: %D = name_ref d, %d +// CHECK:STDOUT: %PackageA.ref: = name_ref PackageA, imports.%PackageA [template = imports.%PackageA] +// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.3 [template = constants.%HasF.type] +// CHECK:STDOUT: %F.ref: %.4 = name_ref F, imports.%import_ref.5 [template = constants.%.5] +// CHECK:STDOUT: %.loc8: %F.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%F.2] +// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc8() +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%Self.1: %HasF.type) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- use_cg.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %TestCG.type: type = fn_type @TestCG [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %TestCG: %TestCG.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %HasG.type: type = facet_type <@HasG> [template] +// CHECK:STDOUT: %Self.1: %HasG.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %G.type.1: type = fn_type @G.1 [template] +// CHECK:STDOUT: %G.1: %G.type.1 = struct_value () [template] +// CHECK:STDOUT: %.4: type = assoc_entity_type %HasG.type, %G.type.1 [template] +// CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.7 [template] +// CHECK:STDOUT: %HasF.type: type = facet_type <@HasF> [template] +// CHECK:STDOUT: %Self.2: %HasF.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %D: type = class_type @D [template] +// CHECK:STDOUT: %G.type.2: type = fn_type @G.2 [template] +// CHECK:STDOUT: %G.2: %G.type.2 = struct_value () [template] +// CHECK:STDOUT: %.6: = interface_witness (%G.2) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %PackageA: = namespace file.%PackageA.import, [template] { +// CHECK:STDOUT: .C = %import_ref.1 +// CHECK:STDOUT: import PackageA//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageB: = namespace file.%PackageB.import, [template] { +// CHECK:STDOUT: .HasG = %import_ref.3 +// CHECK:STDOUT: import PackageB//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref PackageA//default, inst+12, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.2 = import_ref PackageA//default, inst+13, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref PackageB//default, inst+3, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.4 = import_ref PackageB//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.5: %.4 = import_ref PackageB//default, inst+12, loaded [template = constants.%.5] +// CHECK:STDOUT: %import_ref.6 = import_ref PackageB//default, inst+7, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref PackageB//default, inst+7, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref PackageA//default, inst+3, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref PackageA//default, inst+10, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref PackageA//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.11: type = import_ref PackageA//default, inst+17, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.12: type = import_ref PackageA//default, inst+18, loaded [template = constants.%HasF.type] +// CHECK:STDOUT: %import_ref.13 = import_ref PackageA//default, inst+23, unloaded +// CHECK:STDOUT: %import_ref.14: type = import_ref PackageB//default, inst+24, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.15: type = import_ref PackageB//default, inst+25, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.16: = import_ref PackageB//default, inst+30, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.17 = import_ref PackageB//default, inst+15, unloaded +// CHECK:STDOUT: %import_ref.18: type = import_ref PackageB//default, inst+33, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.19: type = import_ref PackageB//default, inst+42, loaded [template = constants.%HasF.type] +// CHECK:STDOUT: %import_ref.20 = import_ref PackageB//default, inst+50, unloaded +// CHECK:STDOUT: %import_ref.21: type = import_ref PackageB//default, inst+53, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.22: type = import_ref PackageB//default, inst+54, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.23 = import_ref PackageB//default, inst+59, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .PackageA = imports.%PackageA +// CHECK:STDOUT: .PackageB = imports.%PackageB +// CHECK:STDOUT: .TestCG = %TestCG.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageA.import = import PackageA +// CHECK:STDOUT: %PackageB.import = import PackageB // CHECK:STDOUT: %TestCG.decl: %TestCG.type = fn_decl @TestCG [template = constants.%TestCG] { // CHECK:STDOUT: %c.patt: %C = binding_pattern c // CHECK:STDOUT: %c.param_patt: %C = value_param_pattern %c.patt, runtime_param0 @@ -423,49 +656,40 @@ fn TestDG(d: PackageB.D) { // CHECK:STDOUT: %c.param: %C = value_param runtime_param0 // CHECK:STDOUT: %c: %C = bind_name c, %c.param // CHECK:STDOUT: } -// CHECK:STDOUT: %TestDG.decl: %TestDG.type = fn_decl @TestDG [template = constants.%TestDG] { -// CHECK:STDOUT: %d.patt: %D = binding_pattern d -// CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, runtime_param0 -// CHECK:STDOUT: } { -// CHECK:STDOUT: %PackageB.ref.loc17: = name_ref PackageB, imports.%PackageB [template = imports.%PackageB] -// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.11 [template = constants.%D] -// CHECK:STDOUT: %d.param: %D = value_param runtime_param0 -// CHECK:STDOUT: %d: %D = bind_name d, %d.param -// CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @HasF { +// CHECK:STDOUT: interface @HasG { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = imports.%import_ref.4 -// CHECK:STDOUT: .F = imports.%import_ref.5 +// CHECK:STDOUT: .G = imports.%import_ref.5 // CHECK:STDOUT: witness = (imports.%import_ref.6) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @HasG { +// CHECK:STDOUT: interface @HasF { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.13 -// CHECK:STDOUT: .G = imports.%import_ref.14 -// CHECK:STDOUT: witness = (imports.%import_ref.15) +// CHECK:STDOUT: .Self = imports.%import_ref.8 +// CHECK:STDOUT: .F = imports.%import_ref.9 +// CHECK:STDOUT: witness = (imports.%import_ref.10) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl.1: imports.%import_ref.8 as imports.%import_ref.9 { +// CHECK:STDOUT: impl @impl.1: imports.%import_ref.11 as imports.%import_ref.12 { // CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = imports.%import_ref.10 +// CHECK:STDOUT: witness = imports.%import_ref.13 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl.2: imports.%import_ref.16 as imports.%import_ref.17 { +// CHECK:STDOUT: impl @impl.2: imports.%import_ref.14 as imports.%import_ref.15 { // CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = imports.%import_ref.18 +// CHECK:STDOUT: witness = imports.%import_ref.16 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl.3: imports.%import_ref.19 as imports.%import_ref.20 { +// CHECK:STDOUT: impl @impl.3: imports.%import_ref.18 as imports.%import_ref.19 { // CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = imports.%import_ref.21 +// CHECK:STDOUT: witness = imports.%import_ref.20 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl.4: imports.%import_ref.22 as imports.%import_ref.23 { +// CHECK:STDOUT: impl @impl.4: imports.%import_ref.21 as imports.%import_ref.22 { // CHECK:STDOUT: !members: -// CHECK:STDOUT: witness = imports.%import_ref.24 +// CHECK:STDOUT: witness = imports.%import_ref.23 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: class @C { @@ -475,72 +699,288 @@ fn TestDG(d: PackageB.D) { // CHECK:STDOUT: // CHECK:STDOUT: class @D { // CHECK:STDOUT: !members: -// CHECK:STDOUT: .Self = imports.%import_ref.12 +// CHECK:STDOUT: .Self = imports.%import_ref.17 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @TestCF(%c.param_patt: %C) { +// CHECK:STDOUT: fn @TestCG(%c.param_patt: %C) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %PackageA.ref.loc6: = name_ref PackageA, imports.%PackageA [template = imports.%PackageA] -// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.3 [template = constants.%HasF.type] -// CHECK:STDOUT: %F.ref: %.4 = name_ref F, imports.%import_ref.5 [template = constants.%.5] -// CHECK:STDOUT: %.loc6: %F.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%F.2] -// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc6() +// CHECK:STDOUT: %PackageB.ref: = name_ref PackageB, imports.%PackageB [template = imports.%PackageB] +// CHECK:STDOUT: %HasG.ref: type = name_ref HasG, imports.%import_ref.3 [template = constants.%HasG.type] +// CHECK:STDOUT: %G.ref: %.4 = name_ref G, imports.%import_ref.5 [template = constants.%.5] +// CHECK:STDOUT: %.loc8: %G.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%G.2] +// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %.loc8() // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @F.1(constants.%Self.1: %HasF.type) { +// CHECK:STDOUT: generic fn @G.1(constants.%Self.1: %HasG.type) { // CHECK:STDOUT: // CHECK:STDOUT: fn(); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: fn @G.2(); // CHECK:STDOUT: -// CHECK:STDOUT: fn @TestDF(%d.param_patt: %D) { +// CHECK:STDOUT: specific @G.1(constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- use_dg.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %D: type = class_type @D [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %TestDG.type: type = fn_type @TestDG [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %TestDG: %TestDG.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %HasG.type: type = facet_type <@HasG> [template] +// CHECK:STDOUT: %Self.1: %HasG.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %G.type.1: type = fn_type @G.1 [template] +// CHECK:STDOUT: %G.1: %G.type.1 = struct_value () [template] +// CHECK:STDOUT: %.4: type = assoc_entity_type %HasG.type, %G.type.1 [template] +// CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.7 [template] +// CHECK:STDOUT: %C: type = class_type @C [template] +// CHECK:STDOUT: %HasF.type: type = facet_type <@HasF> [template] +// CHECK:STDOUT: %Self.2: %HasF.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %G.type.2: type = fn_type @G.2 [template] +// CHECK:STDOUT: %G.2: %G.type.2 = struct_value () [template] +// CHECK:STDOUT: %.6: = interface_witness (%G.2) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %PackageB: = namespace file.%PackageB.import, [template] { +// CHECK:STDOUT: .D = %import_ref.1 +// CHECK:STDOUT: .HasG = %import_ref.3 +// CHECK:STDOUT: import PackageB//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref PackageB//default, inst+14, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.2 = import_ref PackageB//default, inst+15, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref PackageB//default, inst+3, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.4 = import_ref PackageB//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.5: %.4 = import_ref PackageB//default, inst+12, loaded [template = constants.%.5] +// CHECK:STDOUT: %import_ref.6 = import_ref PackageB//default, inst+7, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref PackageB//default, inst+7, unloaded +// CHECK:STDOUT: %import_ref.8 = import_ref PackageB//default, inst+23, unloaded +// CHECK:STDOUT: %import_ref.9: type = import_ref PackageB//default, inst+24, loaded [template = constants.%C] +// CHECK:STDOUT: %import_ref.10: type = import_ref PackageB//default, inst+25, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.11 = import_ref PackageB//default, inst+30, unloaded +// CHECK:STDOUT: %import_ref.12 = import_ref PackageB//default, inst+39, unloaded +// CHECK:STDOUT: %import_ref.13 = import_ref PackageB//default, inst+40, unloaded +// CHECK:STDOUT: %import_ref.14 = import_ref PackageB//default, inst+41, unloaded +// CHECK:STDOUT: %import_ref.15: type = import_ref PackageB//default, inst+33, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.16: type = import_ref PackageB//default, inst+42, loaded [template = constants.%HasF.type] +// CHECK:STDOUT: %import_ref.17 = import_ref PackageB//default, inst+50, unloaded +// CHECK:STDOUT: %import_ref.18: type = import_ref PackageB//default, inst+53, loaded [template = constants.%D] +// CHECK:STDOUT: %import_ref.19: type = import_ref PackageB//default, inst+54, loaded [template = constants.%HasG.type] +// CHECK:STDOUT: %import_ref.20: = import_ref PackageB//default, inst+59, loaded [template = constants.%.6] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .PackageB = imports.%PackageB +// CHECK:STDOUT: .TestDG = %TestDG.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageB.import = import PackageB +// CHECK:STDOUT: %TestDG.decl: %TestDG.type = fn_decl @TestDG [template = constants.%TestDG] { +// CHECK:STDOUT: %d.patt: %D = binding_pattern d +// CHECK:STDOUT: %d.param_patt: %D = value_param_pattern %d.patt, runtime_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %PackageB.ref.loc6: = name_ref PackageB, imports.%PackageB [template = imports.%PackageB] +// CHECK:STDOUT: %D.ref: type = name_ref D, imports.%import_ref.1 [template = constants.%D] +// CHECK:STDOUT: %d.param: %D = value_param runtime_param0 +// CHECK:STDOUT: %d: %D = bind_name d, %d.param +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @HasG { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .G = imports.%import_ref.5 +// CHECK:STDOUT: witness = (imports.%import_ref.6) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @HasF { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.12 +// CHECK:STDOUT: .F = imports.%import_ref.13 +// CHECK:STDOUT: witness = (imports.%import_ref.14) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.1: imports.%import_ref.9 as imports.%import_ref.10 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.11 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.2: imports.%import_ref.15 as imports.%import_ref.16 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.17 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl.3: imports.%import_ref.18 as imports.%import_ref.19 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.20 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @D { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @C { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.8 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @TestDG(%d.param_patt: %D) { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %d.ref: %D = name_ref d, %d -// CHECK:STDOUT: %PackageA.ref: = name_ref PackageA, imports.%PackageA [template = imports.%PackageA] -// CHECK:STDOUT: %HasF.ref: type = name_ref HasF, imports.%import_ref.3 [template = constants.%HasF.type] -// CHECK:STDOUT: %F.ref: %.4 = name_ref F, imports.%import_ref.5 [template = constants.%.5] -// CHECK:STDOUT: %.loc10: %F.type.1 = interface_witness_access constants.%.7, element0 [template = constants.%F.3] -// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc10() +// CHECK:STDOUT: %PackageB.ref.loc7: = name_ref PackageB, imports.%PackageB [template = imports.%PackageB] +// CHECK:STDOUT: %HasG.ref: type = name_ref HasG, imports.%import_ref.3 [template = constants.%HasG.type] +// CHECK:STDOUT: %G.ref: %.4 = name_ref G, imports.%import_ref.5 [template = constants.%.5] +// CHECK:STDOUT: %.loc7: %G.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%G.2] +// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %.loc7() // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.3(); +// CHECK:STDOUT: generic fn @G.1(constants.%Self.1: %HasG.type) { // CHECK:STDOUT: -// CHECK:STDOUT: fn @TestCG(%c.param_patt: %C) { +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @G.2(); +// CHECK:STDOUT: +// CHECK:STDOUT: specific @G.1(constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- package_foo.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %A.type: type = facet_type <@A> [template] +// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] +// CHECK:STDOUT: %.1: type = assoc_entity_type %A.type, %F.type.1 [template] +// CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @A.%F.decl [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %.3: = interface_witness (%F.2) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .A = %A.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %A.decl: type = interface_decl @A [template = constants.%A.type] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %.loc8_7.1: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %.loc8_7.2: type = converted %.loc8_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @A { +// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {} +// CHECK:STDOUT: %.loc5: %.1 = assoc_entity element0, %F.decl [template = constants.%.2] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .F = %.loc5 +// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %.loc8_7.2 as %A.ref { +// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {} +// CHECK:STDOUT: %.loc8_14: = interface_witness (%F.decl) [template = constants.%.3] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: witness = %.loc8_14 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(@A.%Self: %A.type) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %c.ref: %C = name_ref c, %c -// CHECK:STDOUT: %PackageB.ref: = name_ref PackageB, imports.%PackageB [template = imports.%PackageB] -// CHECK:STDOUT: %HasG.ref: type = name_ref HasG, imports.%import_ref.25 [template = constants.%HasG.type] -// CHECK:STDOUT: %G.ref: %.8 = name_ref G, imports.%import_ref.14 [template = constants.%.9] -// CHECK:STDOUT: %.loc14: %G.type.1 = interface_witness_access constants.%.10, element0 [template = constants.%G.2] -// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %.loc14() // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @G.1(constants.%Self.2: %HasG.type) { +// CHECK:STDOUT: specific @F.1(constants.%Self) {} // CHECK:STDOUT: -// CHECK:STDOUT: fn(); +// CHECK:STDOUT: specific @F.1(constants.%empty_tuple.type) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- use_package_foo.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %G.type: type = fn_type @G [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %G: %G.type = struct_value () [template] +// CHECK:STDOUT: %A.type: type = facet_type <@A> [template] +// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] +// CHECK:STDOUT: %.1: type = assoc_entity_type %A.type, %F.type.1 [template] +// CHECK:STDOUT: %.2: %.1 = assoc_entity element0, imports.%import_ref.5 [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %.3: = interface_witness (%F.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G.2(); +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %PackageFoo: = namespace file.%PackageFoo.import, [template] { +// CHECK:STDOUT: .A = %import_ref.1 +// CHECK:STDOUT: import PackageFoo//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: type = import_ref PackageFoo//default, inst+1, loaded [template = constants.%A.type] +// CHECK:STDOUT: %import_ref.2 = import_ref PackageFoo//default, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %.1 = import_ref PackageFoo//default, inst+10, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.4 = import_ref PackageFoo//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref PackageFoo//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.6: type = import_ref PackageFoo//default, inst+13, loaded [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %import_ref.7: type = import_ref PackageFoo//default, inst+14, loaded [template = constants.%A.type] +// CHECK:STDOUT: %import_ref.8: = import_ref PackageFoo//default, inst+19, loaded [template = constants.%.3] +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @TestDG(%d.param_patt: %D) { +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .PackageFoo = imports.%PackageFoo +// CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageFoo.import = import PackageFoo +// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @A { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: .F = imports.%import_ref.3 +// CHECK:STDOUT: witness = (imports.%import_ref.4) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: imports.%import_ref.6 as imports.%import_ref.7 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.8 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @G() { // CHECK:STDOUT: !entry: -// CHECK:STDOUT: %d.ref: %D = name_ref d, %d -// CHECK:STDOUT: %PackageB.ref.loc18: = name_ref PackageB, imports.%PackageB [template = imports.%PackageB] -// CHECK:STDOUT: %HasG.ref: type = name_ref HasG, imports.%import_ref.25 [template = constants.%HasG.type] -// CHECK:STDOUT: %G.ref: %.8 = name_ref G, imports.%import_ref.14 [template = constants.%.9] -// CHECK:STDOUT: %.loc18: %G.type.1 = interface_witness_access constants.%.11, element0 [template = constants.%G.3] -// CHECK:STDOUT: %G.call: init %empty_tuple.type = call %.loc18() +// CHECK:STDOUT: %.loc7_4: %empty_tuple.type = tuple_literal () +// CHECK:STDOUT: %PackageFoo.ref: = name_ref PackageFoo, imports.%PackageFoo [template = imports.%PackageFoo] +// CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.1 [template = constants.%A.type] +// CHECK:STDOUT: %F.ref: %.1 = name_ref F, imports.%import_ref.3 [template = constants.%.2] +// CHECK:STDOUT: %.loc7_5: %F.type.1 = interface_witness_access constants.%.3, element0 [template = constants.%F.2] +// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc7_5() // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G.3(); +// CHECK:STDOUT: generic fn @F.1(constants.%Self: %A.type) { // CHECK:STDOUT: -// CHECK:STDOUT: specific @F.1(constants.%Self.1) {} +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @G.1(constants.%Self.2) {} +// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%Self) {} // CHECK:STDOUT: From 238456d8b891feba7949f3bd62f23f7879f13466 Mon Sep 17 00:00:00 2001 From: Josh L Date: Tue, 12 Nov 2024 00:07:54 +0000 Subject: [PATCH 2/3] Checkpoint progress. --- .../impl/lookup/no_prelude/import.carbon | 634 ++++++++++++++++-- 1 file changed, 560 insertions(+), 74 deletions(-) diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon index 3406f8e4f6706..5229d6fd8aa91 100644 --- a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon +++ b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon @@ -93,26 +93,69 @@ fn TestDG(d: PackageB.D) { d.(PackageB.HasG.G)(); } -// --- package_foo.carbon +// --- associated_interface.carbon -package PackageFoo; +package PackageAssociatedInterface; -interface A { - fn F(); +interface Z { + fn H(); } -impl () as A { - fn F() {} +impl () as Z { + fn H() {} +} + +// --- import_associated_interface.carbon + +package PackageImportAssociatedInterface; + +import PackageAssociatedInterface; + +fn J() { + ().(PackageAssociatedInterface.Z.H)(); +} + +// --- has_param.carbon + +package PackageHasParam; + +class AnyParam[T:! type](X:! T) {} + +interface Y { + fn K() {} } -// --- use_package_foo.carbon +// --- has_generic_interface.carbon + +package PackageGenericInterface; + +import PackageHasParam; + +interface GenericInterface(U:! type) {} + +impl PackageHasParam.AnyParam(GenericInterface) as PackageHasParam.Y { + fn K() {} +} + +fn L() { + var obj: PackageHasParam.AnyParam(GenericInterface) = {}; + obj.(PackageHasParam.Y.K)(); +} + +// --- use_generic_interface_as_param.carbon library "[[@TEST_NAME]]"; -import PackageFoo; +import PackageHasParam; +import PackageGenericInterface; -fn G() { - ().(PackageFoo.A.F)(); +fn M() { + var obj: PackageHasParam.AnyParam( + PackageGenericInterface.GenericInterface) = {}; + // CHECK:STDERR: use_generic_interface_as_param.carbon:[[@LINE+3]]:3: error: cannot access member of interface `Y` in type `AnyParam` that does not implement that interface [MissingImplInMemberAccess] + // CHECK:STDERR: obj.(PackageHasParam.Y.K)(); + // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ + obj.(PackageHasParam.Y.K)(); } // CHECK:STDOUT: --- package_a.carbon @@ -850,112 +893,112 @@ fn G() { // CHECK:STDOUT: // CHECK:STDOUT: specific @G.1(constants.%Self.1) {} // CHECK:STDOUT: -// CHECK:STDOUT: --- package_foo.carbon +// CHECK:STDOUT: --- associated_interface.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %A.type: type = facet_type <@A> [template] -// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic] -// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] +// CHECK:STDOUT: %Z.type: type = facet_type <@Z> [template] +// CHECK:STDOUT: %Self: %Z.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %H.type.1: type = fn_type @H.1 [template] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] -// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] -// CHECK:STDOUT: %.1: type = assoc_entity_type %A.type, %F.type.1 [template] -// CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @A.%F.decl [template] -// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] -// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] -// CHECK:STDOUT: %.3: = interface_witness (%F.2) [template] +// CHECK:STDOUT: %H.1: %H.type.1 = struct_value () [template] +// CHECK:STDOUT: %.1: type = assoc_entity_type %Z.type, %H.type.1 [template] +// CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @Z.%H.decl [template] +// CHECK:STDOUT: %H.type.2: type = fn_type @H.2 [template] +// CHECK:STDOUT: %H.2: %H.type.2 = struct_value () [template] +// CHECK:STDOUT: %.3: = interface_witness (%H.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .A = %A.decl +// CHECK:STDOUT: .Z = %Z.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %A.decl: type = interface_decl @A [template = constants.%A.type] {} {} +// CHECK:STDOUT: %Z.decl: type = interface_decl @Z [template = constants.%Z.type] {} {} // CHECK:STDOUT: impl_decl @impl [template] {} { // CHECK:STDOUT: %.loc8_7.1: %empty_tuple.type = tuple_literal () // CHECK:STDOUT: %.loc8_7.2: type = converted %.loc8_7.1, constants.%empty_tuple.type [template = constants.%empty_tuple.type] -// CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [template = constants.%A.type] +// CHECK:STDOUT: %Z.ref: type = name_ref Z, file.%Z.decl [template = constants.%Z.type] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @A { -// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] -// CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {} {} -// CHECK:STDOUT: %.loc5: %.1 = assoc_entity element0, %F.decl [template = constants.%.2] +// CHECK:STDOUT: interface @Z { +// CHECK:STDOUT: %Self: %Z.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %H.decl: %H.type.1 = fn_decl @H.1 [template = constants.%H.1] {} {} +// CHECK:STDOUT: %.loc5: %.1 = assoc_entity element0, %H.decl [template = constants.%.2] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = %Self -// CHECK:STDOUT: .F = %.loc5 -// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: .H = %.loc5 +// CHECK:STDOUT: witness = (%H.decl) // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: impl @impl: %.loc8_7.2 as %A.ref { -// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {} -// CHECK:STDOUT: %.loc8_14: = interface_witness (%F.decl) [template = constants.%.3] +// CHECK:STDOUT: impl @impl: %.loc8_7.2 as %Z.ref { +// CHECK:STDOUT: %H.decl: %H.type.2 = fn_decl @H.2 [template = constants.%H.2] {} {} +// CHECK:STDOUT: %.loc8_14: = interface_witness (%H.decl) [template = constants.%.3] // CHECK:STDOUT: // CHECK:STDOUT: !members: -// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: .H = %H.decl // CHECK:STDOUT: witness = %.loc8_14 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @F.1(@A.%Self: %A.type) { +// CHECK:STDOUT: generic fn @H.1(@Z.%Self: %Z.type) { // CHECK:STDOUT: // CHECK:STDOUT: fn(); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2() { +// CHECK:STDOUT: fn @H.2() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: specific @H.1(constants.%Self) {} // CHECK:STDOUT: -// CHECK:STDOUT: specific @F.1(constants.%empty_tuple.type) {} +// CHECK:STDOUT: specific @H.1(constants.%empty_tuple.type) {} // CHECK:STDOUT: -// CHECK:STDOUT: --- use_package_foo.carbon +// CHECK:STDOUT: --- import_associated_interface.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { -// CHECK:STDOUT: %G.type: type = fn_type @G [template] +// CHECK:STDOUT: %J.type: type = fn_type @J [template] // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] -// CHECK:STDOUT: %G: %G.type = struct_value () [template] -// CHECK:STDOUT: %A.type: type = facet_type <@A> [template] -// CHECK:STDOUT: %Self: %A.type = bind_symbolic_name Self, 0 [symbolic] -// CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template] -// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template] -// CHECK:STDOUT: %.1: type = assoc_entity_type %A.type, %F.type.1 [template] +// CHECK:STDOUT: %J: %J.type = struct_value () [template] +// CHECK:STDOUT: %Z.type: type = facet_type <@Z> [template] +// CHECK:STDOUT: %Self: %Z.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %H.type.1: type = fn_type @H.1 [template] +// CHECK:STDOUT: %H.1: %H.type.1 = struct_value () [template] +// CHECK:STDOUT: %.1: type = assoc_entity_type %Z.type, %H.type.1 [template] // CHECK:STDOUT: %.2: %.1 = assoc_entity element0, imports.%import_ref.5 [template] -// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] -// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] -// CHECK:STDOUT: %.3: = interface_witness (%F.2) [template] +// CHECK:STDOUT: %H.type.2: type = fn_type @H.2 [template] +// CHECK:STDOUT: %H.2: %H.type.2 = struct_value () [template] +// CHECK:STDOUT: %.3: = interface_witness (%H.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { -// CHECK:STDOUT: %PackageFoo: = namespace file.%PackageFoo.import, [template] { -// CHECK:STDOUT: .A = %import_ref.1 -// CHECK:STDOUT: import PackageFoo//default +// CHECK:STDOUT: %PackageAssociatedInterface: = namespace file.%PackageAssociatedInterface.import, [template] { +// CHECK:STDOUT: .Z = %import_ref.1 +// CHECK:STDOUT: import PackageAssociatedInterface//default // CHECK:STDOUT: } -// CHECK:STDOUT: %import_ref.1: type = import_ref PackageFoo//default, inst+1, loaded [template = constants.%A.type] -// CHECK:STDOUT: %import_ref.2 = import_ref PackageFoo//default, inst+3, unloaded -// CHECK:STDOUT: %import_ref.3: %.1 = import_ref PackageFoo//default, inst+10, loaded [template = constants.%.2] -// CHECK:STDOUT: %import_ref.4 = import_ref PackageFoo//default, inst+5, unloaded -// CHECK:STDOUT: %import_ref.5 = import_ref PackageFoo//default, inst+5, unloaded -// CHECK:STDOUT: %import_ref.6: type = import_ref PackageFoo//default, inst+13, loaded [template = constants.%empty_tuple.type] -// CHECK:STDOUT: %import_ref.7: type = import_ref PackageFoo//default, inst+14, loaded [template = constants.%A.type] -// CHECK:STDOUT: %import_ref.8: = import_ref PackageFoo//default, inst+19, loaded [template = constants.%.3] +// CHECK:STDOUT: %import_ref.1: type = import_ref PackageAssociatedInterface//default, inst+1, loaded [template = constants.%Z.type] +// CHECK:STDOUT: %import_ref.2 = import_ref PackageAssociatedInterface//default, inst+3, unloaded +// CHECK:STDOUT: %import_ref.3: %.1 = import_ref PackageAssociatedInterface//default, inst+10, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.4 = import_ref PackageAssociatedInterface//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.5 = import_ref PackageAssociatedInterface//default, inst+5, unloaded +// CHECK:STDOUT: %import_ref.6: type = import_ref PackageAssociatedInterface//default, inst+13, loaded [template = constants.%empty_tuple.type] +// CHECK:STDOUT: %import_ref.7: type = import_ref PackageAssociatedInterface//default, inst+14, loaded [template = constants.%Z.type] +// CHECK:STDOUT: %import_ref.8: = import_ref PackageAssociatedInterface//default, inst+19, loaded [template = constants.%.3] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { -// CHECK:STDOUT: .PackageFoo = imports.%PackageFoo -// CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: .PackageAssociatedInterface = imports.%PackageAssociatedInterface +// CHECK:STDOUT: .J = %J.decl // CHECK:STDOUT: } -// CHECK:STDOUT: %PackageFoo.import = import PackageFoo -// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {} {} +// CHECK:STDOUT: %PackageAssociatedInterface.import = import PackageAssociatedInterface +// CHECK:STDOUT: %J.decl: %J.type = fn_decl @J [template = constants.%J] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: interface @A { +// CHECK:STDOUT: interface @Z { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = imports.%import_ref.2 -// CHECK:STDOUT: .F = imports.%import_ref.3 +// CHECK:STDOUT: .H = imports.%import_ref.3 // CHECK:STDOUT: witness = (imports.%import_ref.4) // CHECK:STDOUT: } // CHECK:STDOUT: @@ -964,23 +1007,466 @@ fn G() { // CHECK:STDOUT: witness = imports.%import_ref.8 // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @G() { +// CHECK:STDOUT: fn @J() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc7_4: %empty_tuple.type = tuple_literal () -// CHECK:STDOUT: %PackageFoo.ref: = name_ref PackageFoo, imports.%PackageFoo [template = imports.%PackageFoo] -// CHECK:STDOUT: %A.ref: type = name_ref A, imports.%import_ref.1 [template = constants.%A.type] -// CHECK:STDOUT: %F.ref: %.1 = name_ref F, imports.%import_ref.3 [template = constants.%.2] -// CHECK:STDOUT: %.loc7_5: %F.type.1 = interface_witness_access constants.%.3, element0 [template = constants.%F.2] -// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc7_5() +// CHECK:STDOUT: %PackageAssociatedInterface.ref: = name_ref PackageAssociatedInterface, imports.%PackageAssociatedInterface [template = imports.%PackageAssociatedInterface] +// CHECK:STDOUT: %Z.ref: type = name_ref Z, imports.%import_ref.1 [template = constants.%Z.type] +// CHECK:STDOUT: %H.ref: %.1 = name_ref H, imports.%import_ref.3 [template = constants.%.2] +// CHECK:STDOUT: %.loc7_5: %H.type.1 = interface_witness_access constants.%.3, element0 [template = constants.%H.2] +// CHECK:STDOUT: %H.call: init %empty_tuple.type = call %.loc7_5() // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @F.1(constants.%Self: %A.type) { +// CHECK:STDOUT: generic fn @H.1(constants.%Self: %Z.type) { // CHECK:STDOUT: // CHECK:STDOUT: fn(); // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: fn @H.2(); // CHECK:STDOUT: -// CHECK:STDOUT: specific @F.1(constants.%Self) {} +// CHECK:STDOUT: specific @H.1(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- has_param.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %X: %T = bind_symbolic_name X, 1 [symbolic] +// CHECK:STDOUT: %X.patt: %T = symbolic_binding_pattern X, 1 [symbolic] +// CHECK:STDOUT: %AnyParam.type: type = generic_class_type @AnyParam [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %AnyParam.1: %AnyParam.type = struct_value () [template] +// CHECK:STDOUT: %AnyParam.2: type = class_type @AnyParam, @AnyParam(%T, %X) [symbolic] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %Y.type: type = facet_type <@Y> [template] +// CHECK:STDOUT: %Self: %Y.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %K.type: type = fn_type @K [template] +// CHECK:STDOUT: %K: %K.type = struct_value () [template] +// CHECK:STDOUT: %.3: type = assoc_entity_type %Y.type, %K.type [template] +// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, @Y.%K.decl [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .AnyParam = %AnyParam.decl +// CHECK:STDOUT: .Y = %Y.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %AnyParam.decl: %AnyParam.type = class_decl @AnyParam [template = constants.%AnyParam.1] { +// CHECK:STDOUT: %T.patt.loc4_16.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_16.2 (constants.%T.patt)] +// CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_16.1, runtime_param [symbolic = %T.patt.loc4_16.2 (constants.%T.patt)] +// CHECK:STDOUT: %X.patt.loc4_26.1: @AnyParam.%T.loc4_16.2 (%T) = symbolic_binding_pattern X, 1 [symbolic = %X.patt.loc4_26.2 (constants.%X.patt)] +// CHECK:STDOUT: %X.param_patt: @AnyParam.%T.loc4_16.2 (%T) = value_param_pattern %X.patt.loc4_26.1, runtime_param [symbolic = %X.patt.loc4_26.2 (constants.%X.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4_16.1 [symbolic = %T.loc4_16.2 (constants.%T)] +// CHECK:STDOUT: %T.param: type = value_param runtime_param +// CHECK:STDOUT: %T.loc4_16.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_16.2 (constants.%T)] +// CHECK:STDOUT: %X.param: @AnyParam.%T.loc4_16.2 (%T) = value_param runtime_param +// CHECK:STDOUT: %X.loc4_26.1: @AnyParam.%T.loc4_16.2 (%T) = bind_symbolic_name X, 1, %X.param [symbolic = %X.loc4_26.2 (constants.%X)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %Y.decl: type = interface_decl @Y [template = constants.%Y.type] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Y { +// CHECK:STDOUT: %Self: %Y.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self] +// CHECK:STDOUT: %K.decl: %K.type = fn_decl @K [template = constants.%K] {} {} +// CHECK:STDOUT: %.loc7: %.3 = assoc_entity element0, %K.decl [template = constants.%.4] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self +// CHECK:STDOUT: .K = %.loc7 +// CHECK:STDOUT: witness = (%K.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @AnyParam(%T.loc4_16.1: type, %X.loc4_26.1: @AnyParam.%T.loc4_16.2 (%T)) { +// CHECK:STDOUT: %T.loc4_16.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_16.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc4_16.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_16.2 (constants.%T.patt)] +// CHECK:STDOUT: %X.loc4_26.2: %T = bind_symbolic_name X, 1 [symbolic = %X.loc4_26.2 (constants.%X)] +// CHECK:STDOUT: %X.patt.loc4_26.2: %T = symbolic_binding_pattern X, 1 [symbolic = %X.patt.loc4_26.2 (constants.%X.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %.loc4: = complete_type_witness %.1 [template = constants.%.2] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%AnyParam.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @K(@Y.%Self: %Y.type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AnyParam(constants.%T, constants.%X) { +// CHECK:STDOUT: %T.loc4_16.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc4_16.2 => constants.%T +// CHECK:STDOUT: %X.loc4_26.2 => constants.%X +// CHECK:STDOUT: %X.patt.loc4_26.2 => constants.%X +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @K(constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- has_generic_interface.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %GenericInterface.type.1: type = generic_interface_type @GenericInterface [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %GenericInterface: %GenericInterface.type.1 = struct_value () [template] +// CHECK:STDOUT: %GenericInterface.type.2: type = facet_type <@GenericInterface, @GenericInterface(%U)> [symbolic] +// CHECK:STDOUT: %Self.1: %GenericInterface.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %AnyParam.type: type = generic_class_type @AnyParam [template] +// CHECK:STDOUT: %AnyParam.1: %AnyParam.type = struct_value () [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %X.1: %T = bind_symbolic_name X, 1 [symbolic] +// CHECK:STDOUT: %AnyParam.2: type = class_type @AnyParam, @AnyParam(%T, %X.1) [symbolic] +// CHECK:STDOUT: %X.2: @AnyParam.%T (%T) = bind_symbolic_name X, 1 [symbolic] +// CHECK:STDOUT: %X.patt.1: @AnyParam.%T (%T) = symbolic_binding_pattern X, 1 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %X.patt.2: %T = symbolic_binding_pattern X, 1 [symbolic] +// CHECK:STDOUT: %AnyParam.3: type = class_type @AnyParam, @AnyParam(%GenericInterface.type.1, %GenericInterface) [template] +// CHECK:STDOUT: %Y.type: type = facet_type <@Y> [template] +// CHECK:STDOUT: %Self.2: %Y.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %K.type.1: type = fn_type @K.1 [template] +// CHECK:STDOUT: %K.1: %K.type.1 = struct_value () [template] +// CHECK:STDOUT: %K.type.2: type = fn_type @K.2 [template] +// CHECK:STDOUT: %K.2: %K.type.2 = struct_value () [template] +// CHECK:STDOUT: %.3: = interface_witness (%K.1) [template] +// CHECK:STDOUT: %L.type: type = fn_type @L [template] +// CHECK:STDOUT: %L: %L.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = ptr_type %.1 [template] +// CHECK:STDOUT: %struct: %AnyParam.3 = struct_value () [template] +// CHECK:STDOUT: %.5: type = assoc_entity_type %Y.type, %K.type.2 [template] +// CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.7 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %PackageHasParam: = namespace file.%PackageHasParam.import, [template] { +// CHECK:STDOUT: .AnyParam = %import_ref.1 +// CHECK:STDOUT: .Y = %import_ref.3 +// CHECK:STDOUT: import PackageHasParam//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %AnyParam.type = import_ref PackageHasParam//default, inst+14, loaded [template = constants.%AnyParam.1] +// CHECK:STDOUT: %import_ref.2 = import_ref PackageHasParam//default, inst+22, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref PackageHasParam//default, inst+26, loaded [template = constants.%Y.type] +// CHECK:STDOUT: %import_ref.4 = import_ref PackageHasParam//default, inst+28, unloaded +// CHECK:STDOUT: %import_ref.5: %.5 = import_ref PackageHasParam//default, inst+34, loaded [template = constants.%.6] +// CHECK:STDOUT: %import_ref.6: %K.type.2 = import_ref PackageHasParam//default, inst+30, loaded [template = constants.%K.2] +// CHECK:STDOUT: %import_ref.7 = import_ref PackageHasParam//default, inst+30, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .PackageHasParam = imports.%PackageHasParam +// CHECK:STDOUT: .GenericInterface = %GenericInterface.decl +// CHECK:STDOUT: .L = %L.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageHasParam.import = import PackageHasParam +// CHECK:STDOUT: %GenericInterface.decl: %GenericInterface.type.1 = interface_decl @GenericInterface [template = constants.%GenericInterface] { +// CHECK:STDOUT: %U.patt.loc6_28.1: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc6_28.2 (constants.%U.patt)] +// CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc6_28.1, runtime_param [symbolic = %U.patt.loc6_28.2 (constants.%U.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %U.param: type = value_param runtime_param +// CHECK:STDOUT: %U.loc6_28.1: type = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc6_28.2 (constants.%U)] +// CHECK:STDOUT: } +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %PackageHasParam.ref.loc8_6: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %AnyParam.ref: %AnyParam.type = name_ref AnyParam, imports.%import_ref.1 [template = constants.%AnyParam.1] +// CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type.1 = name_ref GenericInterface, file.%GenericInterface.decl [template = constants.%GenericInterface] +// CHECK:STDOUT: %AnyParam: type = class_type @AnyParam, @AnyParam(constants.%GenericInterface.type.1, constants.%GenericInterface) [template = constants.%AnyParam.3] +// CHECK:STDOUT: %PackageHasParam.ref.loc8_52: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %Y.ref: type = name_ref Y, imports.%import_ref.3 [template = constants.%Y.type] +// CHECK:STDOUT: } +// CHECK:STDOUT: %L.decl: %L.type = fn_decl @L [template = constants.%L] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @GenericInterface(%U.loc6_28.1: type) { +// CHECK:STDOUT: %U.loc6_28.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc6_28.2 (constants.%U)] +// CHECK:STDOUT: %U.patt.loc6_28.2: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc6_28.2 (constants.%U.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %GenericInterface.type: type = facet_type <@GenericInterface, @GenericInterface(%U.loc6_28.2)> [symbolic = %GenericInterface.type (constants.%GenericInterface.type.2)] +// CHECK:STDOUT: %Self.2: %GenericInterface.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @GenericInterface.%GenericInterface.type (%GenericInterface.type.2) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.1)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Y { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: .K = imports.%import_ref.5 +// CHECK:STDOUT: witness = (imports.%import_ref.6) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %AnyParam as %Y.ref { +// CHECK:STDOUT: %K.decl: %K.type.1 = fn_decl @K.1 [template = constants.%K.1] {} {} +// CHECK:STDOUT: %.loc8: = interface_witness (%K.decl) [template = constants.%.3] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .K = %K.decl +// CHECK:STDOUT: witness = %.loc8 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @AnyParam(constants.%T: type, constants.%X.2: @AnyParam.%T (%T)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)] +// CHECK:STDOUT: %X: %T = bind_symbolic_name X, 1 [symbolic = %X (constants.%X.1)] +// CHECK:STDOUT: %X.patt: %T = symbolic_binding_pattern X, 1 [symbolic = %X.patt (constants.%X.patt.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @K.1() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @K.2(constants.%Self.2: %Y.type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @L() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %PackageHasParam.ref.loc13: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %AnyParam.ref: %AnyParam.type = name_ref AnyParam, imports.%import_ref.1 [template = constants.%AnyParam.1] +// CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type.1 = name_ref GenericInterface, file.%GenericInterface.decl [template = constants.%GenericInterface] +// CHECK:STDOUT: %AnyParam: type = class_type @AnyParam, @AnyParam(constants.%GenericInterface.type.1, constants.%GenericInterface) [template = constants.%AnyParam.3] +// CHECK:STDOUT: %obj.var: ref %AnyParam.3 = var obj +// CHECK:STDOUT: %obj: ref %AnyParam.3 = bind_name obj, %obj.var +// CHECK:STDOUT: %.loc13_58.1: %.1 = struct_literal () +// CHECK:STDOUT: %.loc13_58.2: init %AnyParam.3 = class_init (), %obj.var [template = constants.%struct] +// CHECK:STDOUT: %.loc13_59: init %AnyParam.3 = converted %.loc13_58.1, %.loc13_58.2 [template = constants.%struct] +// CHECK:STDOUT: assign %obj.var, %.loc13_59 +// CHECK:STDOUT: %obj.ref: ref %AnyParam.3 = name_ref obj, %obj +// CHECK:STDOUT: %PackageHasParam.ref.loc14: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %Y.ref: type = name_ref Y, imports.%import_ref.3 [template = constants.%Y.type] +// CHECK:STDOUT: %K.ref: %.5 = name_ref K, imports.%import_ref.5 [template = constants.%.6] +// CHECK:STDOUT: %.loc14: %K.type.2 = interface_witness_access constants.%.3, element0 [template = constants.%K.1] +// CHECK:STDOUT: %K.call: init %empty_tuple.type = call %.loc14() +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GenericInterface(constants.%U) { +// CHECK:STDOUT: %U.loc6_28.2 => constants.%U +// CHECK:STDOUT: %U.patt.loc6_28.2 => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GenericInterface(@GenericInterface.%U.loc6_28.2) { +// CHECK:STDOUT: %U.loc6_28.2 => constants.%U +// CHECK:STDOUT: %U.patt.loc6_28.2 => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AnyParam(constants.%T, constants.%X.1) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: %X => constants.%X.1 +// CHECK:STDOUT: %X.patt => constants.%X.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AnyParam(constants.%T, constants.%X.2) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: %X => constants.%X.2 +// CHECK:STDOUT: %X.patt => constants.%X.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AnyParam(constants.%GenericInterface.type.1, constants.%GenericInterface) { +// CHECK:STDOUT: %T => constants.%GenericInterface.type.1 +// CHECK:STDOUT: %T.patt => constants.%GenericInterface.type.1 +// CHECK:STDOUT: %X => constants.%GenericInterface +// CHECK:STDOUT: %X.patt => constants.%GenericInterface +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @K.2(constants.%Self.2) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @K.2(constants.%AnyParam.3) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- use_generic_interface_as_param.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %M.type: type = fn_type @M [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %M: %M.type = struct_value () [template] +// CHECK:STDOUT: %AnyParam.type: type = generic_class_type @AnyParam [template] +// CHECK:STDOUT: %AnyParam.1: %AnyParam.type = struct_value () [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %X.1: %T = bind_symbolic_name X, 1 [symbolic] +// CHECK:STDOUT: %AnyParam.2: type = class_type @AnyParam, @AnyParam(%T, %X.1) [symbolic] +// CHECK:STDOUT: %X.2: @AnyParam.%T (%T) = bind_symbolic_name X, 1 [symbolic] +// CHECK:STDOUT: %X.patt.1: @AnyParam.%T (%T) = symbolic_binding_pattern X, 1 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %X.patt.2: %T = symbolic_binding_pattern X, 1 [symbolic] +// CHECK:STDOUT: %GenericInterface.type.1: type = generic_interface_type @GenericInterface [template] +// CHECK:STDOUT: %GenericInterface: %GenericInterface.type.1 = struct_value () [template] +// CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic] +// CHECK:STDOUT: %GenericInterface.type.2: type = facet_type <@GenericInterface, @GenericInterface(%U)> [symbolic] +// CHECK:STDOUT: %Self.1: @GenericInterface.%GenericInterface.type (%GenericInterface.type.2) = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic] +// CHECK:STDOUT: %Self.2: %GenericInterface.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %AnyParam.3: type = class_type @AnyParam, @AnyParam(%GenericInterface.type.1, %GenericInterface) [template] +// CHECK:STDOUT: %.3: type = ptr_type %.1 [template] +// CHECK:STDOUT: %struct: %AnyParam.3 = struct_value () [template] +// CHECK:STDOUT: %Y.type: type = facet_type <@Y> [template] +// CHECK:STDOUT: %Self.3: %Y.type = bind_symbolic_name Self, 0 [symbolic] +// CHECK:STDOUT: %K.type: type = fn_type @K [template] +// CHECK:STDOUT: %K: %K.type = struct_value () [template] +// CHECK:STDOUT: %.4: type = assoc_entity_type %Y.type, %K.type [template] +// CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.9 [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %PackageHasParam: = namespace file.%PackageHasParam.import, [template] { +// CHECK:STDOUT: .AnyParam = %import_ref.1 +// CHECK:STDOUT: .Y = %import_ref.5 +// CHECK:STDOUT: import PackageHasParam//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageGenericInterface: = namespace file.%PackageGenericInterface.import, [template] { +// CHECK:STDOUT: .GenericInterface = %import_ref.3 +// CHECK:STDOUT: import PackageGenericInterface//default +// CHECK:STDOUT: } +// CHECK:STDOUT: %import_ref.1: %AnyParam.type = import_ref PackageHasParam//default, inst+14, loaded [template = constants.%AnyParam.1] +// CHECK:STDOUT: %import_ref.2 = import_ref PackageHasParam//default, inst+22, unloaded +// CHECK:STDOUT: %import_ref.3: %GenericInterface.type.1 = import_ref PackageGenericInterface//default, inst+9, loaded [template = constants.%GenericInterface] +// CHECK:STDOUT: %import_ref.4 = import_ref PackageGenericInterface//default, inst+16, unloaded +// CHECK:STDOUT: %import_ref.5: type = import_ref PackageHasParam//default, inst+26, loaded [template = constants.%Y.type] +// CHECK:STDOUT: %import_ref.6 = import_ref PackageHasParam//default, inst+28, unloaded +// CHECK:STDOUT: %import_ref.7: %.4 = import_ref PackageHasParam//default, inst+34, loaded [template = constants.%.5] +// CHECK:STDOUT: %import_ref.8 = import_ref PackageHasParam//default, inst+30, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref PackageHasParam//default, inst+30, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .PackageHasParam = imports.%PackageHasParam +// CHECK:STDOUT: .PackageGenericInterface = imports.%PackageGenericInterface +// CHECK:STDOUT: .M = %M.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %PackageHasParam.import = import PackageHasParam +// CHECK:STDOUT: %PackageGenericInterface.import = import PackageGenericInterface +// CHECK:STDOUT: %M.decl: %M.type = fn_decl @M [template = constants.%M] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @GenericInterface(constants.%U: type) { +// CHECK:STDOUT: %U: type = bind_symbolic_name U, 0 [symbolic = %U (constants.%U)] +// CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt (constants.%U.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %GenericInterface.type: type = facet_type <@GenericInterface, @GenericInterface(%U)> [symbolic = %GenericInterface.type (constants.%GenericInterface.type.2)] +// CHECK:STDOUT: %Self: %GenericInterface.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.4 +// CHECK:STDOUT: witness = () +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: interface @Y { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .K = imports.%import_ref.7 +// CHECK:STDOUT: witness = (imports.%import_ref.8) +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @AnyParam(constants.%T: type, constants.%X.2: @AnyParam.%T (%T)) { +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt)] +// CHECK:STDOUT: %X: %T = bind_symbolic_name X, 1 [symbolic = %X (constants.%X.1)] +// CHECK:STDOUT: %X.patt: %T = symbolic_binding_pattern X, 1 [symbolic = %X.patt (constants.%X.patt.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @M() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %PackageHasParam.ref.loc8: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %AnyParam.ref: %AnyParam.type = name_ref AnyParam, imports.%import_ref.1 [template = constants.%AnyParam.1] +// CHECK:STDOUT: %PackageGenericInterface.ref: = name_ref PackageGenericInterface, imports.%PackageGenericInterface [template = imports.%PackageGenericInterface] +// CHECK:STDOUT: %GenericInterface.ref: %GenericInterface.type.1 = name_ref GenericInterface, imports.%import_ref.3 [template = constants.%GenericInterface] +// CHECK:STDOUT: %AnyParam: type = class_type @AnyParam, @AnyParam(constants.%GenericInterface.type.1, constants.%GenericInterface) [template = constants.%AnyParam.3] +// CHECK:STDOUT: %obj.var: ref %AnyParam.3 = var obj +// CHECK:STDOUT: %obj: ref %AnyParam.3 = bind_name obj, %obj.var +// CHECK:STDOUT: %.loc9_50.1: %.1 = struct_literal () +// CHECK:STDOUT: %.loc9_50.2: init %AnyParam.3 = class_init (), %obj.var [template = constants.%struct] +// CHECK:STDOUT: %.loc9_51: init %AnyParam.3 = converted %.loc9_50.1, %.loc9_50.2 [template = constants.%struct] +// CHECK:STDOUT: assign %obj.var, %.loc9_51 +// CHECK:STDOUT: %obj.ref: ref %AnyParam.3 = name_ref obj, %obj +// CHECK:STDOUT: %PackageHasParam.ref.loc13: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %Y.ref: type = name_ref Y, imports.%import_ref.5 [template = constants.%Y.type] +// CHECK:STDOUT: %K.ref: %.4 = name_ref K, imports.%import_ref.7 [template = constants.%.5] +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @K(constants.%Self.3: %Y.type) { +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AnyParam(constants.%T, constants.%X.1) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: %X => constants.%X.1 +// CHECK:STDOUT: %X.patt => constants.%X.1 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AnyParam(constants.%T, constants.%X.2) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: %X => constants.%X.2 +// CHECK:STDOUT: %X.patt => constants.%X.2 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GenericInterface(constants.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: %U.patt => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @GenericInterface(@GenericInterface.%U) { +// CHECK:STDOUT: %U => constants.%U +// CHECK:STDOUT: %U.patt => constants.%U +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @AnyParam(constants.%GenericInterface.type.1, constants.%GenericInterface) { +// CHECK:STDOUT: %T => constants.%GenericInterface.type.1 +// CHECK:STDOUT: %T.patt => constants.%GenericInterface.type.1 +// CHECK:STDOUT: %X => constants.%GenericInterface +// CHECK:STDOUT: %X.patt => constants.%GenericInterface +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @K(constants.%Self.3) {} // CHECK:STDOUT: From 0e5f810d35c55ed4d46995bbcc010633a229d421 Mon Sep 17 00:00:00 2001 From: Josh L Date: Tue, 12 Nov 2024 00:35:48 +0000 Subject: [PATCH 3/3] Checkpoint progress. --- toolchain/check/impl_lookup.cpp | 6 ++++-- .../check/testdata/impl/lookup/no_prelude/import.carbon | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/toolchain/check/impl_lookup.cpp b/toolchain/check/impl_lookup.cpp index 8f7f49f2cc048..efe82f545546c 100644 --- a/toolchain/check/impl_lookup.cpp +++ b/toolchain/check/impl_lookup.cpp @@ -62,6 +62,10 @@ static auto FindAssociatedImportIRs(Context& context, add_entity(context.classes().Get(SemIR::ClassId(arg))); break; } + case SemIR::IdKind::For: { + add_entity(context.interfaces().Get(SemIR::InterfaceId(arg))); + break; + } case SemIR::IdKind::For: { const auto& facet_type_info = context.sem_ir().facet_types().Get(SemIR::FacetTypeId(arg)); @@ -75,8 +79,6 @@ static auto FindAssociatedImportIRs(Context& context, break; } default: { - // FIXME: delete - CARBON_CHECK(kind != SemIR::IdKind::For); break; } } diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon index 5229d6fd8aa91..8bdf137791379 100644 --- a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon +++ b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon @@ -142,7 +142,7 @@ fn L() { obj.(PackageHasParam.Y.K)(); } -// --- use_generic_interface_as_param.carbon +// --- fail_todo_use_generic_interface_as_param.carbon library "[[@TEST_NAME]]"; @@ -152,7 +152,7 @@ import PackageGenericInterface; fn M() { var obj: PackageHasParam.AnyParam( PackageGenericInterface.GenericInterface) = {}; - // CHECK:STDERR: use_generic_interface_as_param.carbon:[[@LINE+3]]:3: error: cannot access member of interface `Y` in type `AnyParam` that does not implement that interface [MissingImplInMemberAccess] + // CHECK:STDERR: fail_todo_use_generic_interface_as_param.carbon:[[@LINE+3]]:3: error: cannot access member of interface `Y` in type `AnyParam` that does not implement that interface [MissingImplInMemberAccess] // CHECK:STDERR: obj.(PackageHasParam.Y.K)(); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~ obj.(PackageHasParam.Y.K)(); @@ -1306,7 +1306,7 @@ fn M() { // CHECK:STDOUT: // CHECK:STDOUT: specific @K.2(constants.%AnyParam.3) {} // CHECK:STDOUT: -// CHECK:STDOUT: --- use_generic_interface_as_param.carbon +// CHECK:STDOUT: --- fail_todo_use_generic_interface_as_param.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %M.type: type = fn_type @M [template]