From d0e067ac7586bfcf29c05adfe4b68c9952d4ac67 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 2 Dec 2024 10:49:30 -0800 Subject: [PATCH] Fix impl lookup to look in the arguments of a specific. (#4601) --- toolchain/check/impl_lookup.cpp | 25 +- .../impl/lookup/no_prelude/import.carbon | 34 +- .../lookup/no_prelude/specific_args.carbon | 806 ++++++++++++++++++ 3 files changed, 850 insertions(+), 15 deletions(-) create mode 100644 toolchain/check/testdata/impl/lookup/no_prelude/specific_args.carbon diff --git a/toolchain/check/impl_lookup.cpp b/toolchain/check/impl_lookup.cpp index 1320d104e3d5..43743303aaa1 100644 --- a/toolchain/check/impl_lookup.cpp +++ b/toolchain/check/impl_lookup.cpp @@ -36,6 +36,21 @@ static auto FindAssociatedImportIRs(Context& context, worklist.push_back(context.constant_values().GetInstId(type_const_id)); worklist.push_back(context.constant_values().GetInstId(interface_const_id)); + // Push the contents of an instruction block onto our worklist. + auto push_block = [&](SemIR::InstBlockId block_id) { + if (block_id.is_valid()) { + auto block = context.inst_blocks().Get(block_id); + worklist.append(block.begin(), block.end()); + } + }; + + // Add the arguments of a specific to the worklist. + auto push_args = [&](SemIR::SpecificId specific_id) { + if (specific_id.is_valid()) { + push_block(context.specifics().Get(specific_id).args_id); + } + }; + while (!worklist.empty()) { auto inst_id = worklist.pop_back_val(); @@ -52,10 +67,7 @@ static auto FindAssociatedImportIRs(Context& context, break; } case SemIR::IdKind::For: { - if (auto id = SemIR::InstBlockId(arg); id.is_valid()) { - auto block = context.inst_blocks().Get(id); - worklist.append(block.begin(), block.end()); - } + push_block(SemIR::InstBlockId(arg)); break; } case SemIR::IdKind::For: { @@ -71,6 +83,7 @@ static auto FindAssociatedImportIRs(Context& context, context.facet_types().Get(SemIR::FacetTypeId(arg)); for (const auto& impl : facet_type_info.impls_constraints) { add_entity(context.interfaces().Get(impl.interface_id)); + push_args(impl.specific_id); } break; } @@ -78,6 +91,10 @@ static auto FindAssociatedImportIRs(Context& context, add_entity(context.functions().Get(SemIR::FunctionId(arg))); break; } + case SemIR::IdKind::For: { + push_args(SemIR::SpecificId(arg)); + break; + } default: { break; } diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/import.carbon index 7e6b1505a681..db884895d7fb 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)(); } -// --- fail_todo_use_generic_interface_as_param.carbon +// --- use_generic_interface_as_param.carbon library "[[@TEST_NAME]]"; @@ -152,10 +152,6 @@ import PackageGenericInterface; fn M() { var obj: PackageHasParam.AnyParam( PackageGenericInterface.GenericInterface) = {}; - // CHECK:STDERR: fail_todo_use_generic_interface_as_param.carbon:[[@LINE+4]]: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: ^~~~~~~~~~~~~~~~~~~~~~~~~ - // CHECK:STDERR: obj.(PackageHasParam.Y.K)(); } @@ -1344,10 +1340,11 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: // CHECK:STDOUT: specific @K.2(constants.%.3) {} // CHECK:STDOUT: -// CHECK:STDOUT: --- fail_todo_use_generic_interface_as_param.carbon +// 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] @@ -1368,9 +1365,12 @@ fn Test(c: HasExtraInterfaces.C(type)) { // 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: %.4: type = assoc_entity_type %Y.type, %K.type [template] +// CHECK:STDOUT: %K.type.1: type = fn_type @K.1 [template] +// CHECK:STDOUT: %.4: type = assoc_entity_type %Y.type, %K.type.1 [template] // CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %K.type.2: type = fn_type @K.2 [template] +// CHECK:STDOUT: %K.2: %K.type.2 = struct_value () [template] +// CHECK:STDOUT: %.6: = interface_witness (%K.2) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { @@ -1392,6 +1392,9 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: %import_ref.7 = import_ref PackageHasParam//default, inst+28, unloaded // CHECK:STDOUT: %import_ref.8: %.4 = import_ref PackageHasParam//default, inst+34, loaded [template = constants.%.5] // CHECK:STDOUT: %import_ref.9 = import_ref PackageHasParam//default, inst+30, unloaded +// CHECK:STDOUT: %import_ref.11: type = import_ref PackageGenericInterface//default, inst+46, loaded [template = constants.%AnyParam.3] +// CHECK:STDOUT: %import_ref.12: type = import_ref PackageGenericInterface//default, inst+56, loaded [template = constants.%Y.type] +// CHECK:STDOUT: %import_ref.13: = import_ref PackageGenericInterface//default, inst+65, loaded [template = constants.%.6] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { @@ -1427,6 +1430,11 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: witness = (imports.%import_ref.9) // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: imports.%import_ref.11 as imports.%import_ref.12 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.13 +// 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)] @@ -1456,18 +1464,22 @@ fn Test(c: HasExtraInterfaces.C(type)) { // 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.loc14: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] +// CHECK:STDOUT: %PackageHasParam.ref.loc10: = name_ref PackageHasParam, imports.%PackageHasParam [template = imports.%PackageHasParam] // CHECK:STDOUT: %Y.ref: type = name_ref Y, imports.%import_ref.6 [template = constants.%Y.type] // CHECK:STDOUT: %K.ref: %.4 = name_ref K, imports.%import_ref.8 [template = constants.%.5] +// CHECK:STDOUT: %.loc10: %K.type.1 = interface_witness_access constants.%.6, element0 [template = constants.%K.2] +// CHECK:STDOUT: %K.call: init %empty_tuple.type = call %.loc10() // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: generic fn @K(constants.%Self.3: %Y.type) { +// CHECK:STDOUT: generic fn @K.1(constants.%Self.3: %Y.type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: // CHECK:STDOUT: fn(); // CHECK:STDOUT: } // CHECK:STDOUT: +// CHECK:STDOUT: fn @K.2(); +// CHECK:STDOUT: // CHECK:STDOUT: specific @AnyParam(constants.%T, constants.%X.1) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T @@ -1501,7 +1513,7 @@ fn Test(c: HasExtraInterfaces.C(type)) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: -// CHECK:STDOUT: specific @K(constants.%Self.3) {} +// CHECK:STDOUT: specific @K.1(constants.%Self.3) {} // CHECK:STDOUT: // CHECK:STDOUT: --- has_extra_interfaces.carbon // CHECK:STDOUT: diff --git a/toolchain/check/testdata/impl/lookup/no_prelude/specific_args.carbon b/toolchain/check/testdata/impl/lookup/no_prelude/specific_args.carbon new file mode 100644 index 000000000000..00dd56c909b2 --- /dev/null +++ b/toolchain/check/testdata/impl/lookup/no_prelude/specific_args.carbon @@ -0,0 +1,806 @@ +// Part of the Carbon Language project, under the Apache License v2.0 with LLVM +// Exceptions. See /LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +// AUTOUPDATE +// TIP: To test this file alone, run: +// TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/no_prelude/specific_args.carbon +// TIP: To dump output, run: +// TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/no_prelude/specific_args.carbon + +// --- types.carbon + +library "[[@TEST_NAME]]"; + +interface I(T:! type) { fn F(); } +class C(T:! type) {} + +class X {} + +// --- impl_in_interface_args.carbon + +library "[[@TEST_NAME]]"; +import library "types"; + +class InInterfaceArgs {} + +impl X as I(InInterfaceArgs) { fn F() {} } + +// --- use_impl_in_interface_args.carbon + +library "[[@TEST_NAME]]"; +import library "types"; +import library "impl_in_interface_args"; + +fn G(x: X) { x.(I(InInterfaceArgs).F)(); } + +// --- impl_in_class_args.carbon + +library "[[@TEST_NAME]]"; +import library "types"; + +class InClassArgs {} + +impl C(InClassArgs) as I(X) { fn F() {} } + +// --- use_impl_in_class_args.carbon + +library "[[@TEST_NAME]]"; +import library "types"; +import library "impl_in_class_args"; + +fn H(c: C(InClassArgs)) { c.(I(X).F)(); } + +// CHECK:STDOUT: --- types.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: %I.type.1: type = generic_interface_type @I [template] +// CHECK:STDOUT: %I: %I.type.1 = struct_value () [template] +// CHECK:STDOUT: %I.type.2: type = facet_type <@I, @I(%T)> [symbolic] +// CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %F.type: type = fn_type @F, @I(%T) [symbolic] +// CHECK:STDOUT: %F: %F.type = struct_value () [symbolic] +// CHECK:STDOUT: %.1: type = assoc_entity_type %I.type.2, %F.type [symbolic] +// CHECK:STDOUT: %.2: %.1 = assoc_entity element0, @I.%F.decl [symbolic] +// CHECK:STDOUT: %C.type: type = generic_class_type @C [template] +// CHECK:STDOUT: %C.1: %C.type = struct_value () [template] +// CHECK:STDOUT: %C.2: type = class_type @C, @C(%T) [symbolic] +// CHECK:STDOUT: %.3: type = struct_type {} [template] +// CHECK:STDOUT: %.4: = complete_type_witness %.3 [template] +// CHECK:STDOUT: %X: type = class_type @X [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = %I.decl +// CHECK:STDOUT: .C = %C.decl +// CHECK:STDOUT: .X = %X.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %I.decl: %I.type.1 = interface_decl @I [template = constants.%I] { +// CHECK:STDOUT: %T.patt.loc4_13.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)] +// CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4_13.1, runtime_param [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %T.param: type = value_param runtime_param +// CHECK:STDOUT: %T.loc4_13.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc4_13.2 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] { +// CHECK:STDOUT: %T.patt.loc5_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc5_9.2 (constants.%T.patt)] +// CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc5_9.1, runtime_param [symbolic = %T.patt.loc5_9.2 (constants.%T.patt)] +// CHECK:STDOUT: } { +// CHECK:STDOUT: %T.param: type = value_param runtime_param +// CHECK:STDOUT: %T.loc5_9.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc5_9.2 (constants.%T)] +// CHECK:STDOUT: } +// CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {} +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @I(%T.loc4_13.1: type) { +// CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_13.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc4_13.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T.loc4_13.2)> [symbolic = %I.type (constants.%I.type.2)] +// CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.type: type = fn_type @F, @I(%T.loc4_13.2) [symbolic = %F.type (constants.%F.type)] +// CHECK:STDOUT: %F: @I.%F.type (%F.type) = struct_value () [symbolic = %F (constants.%F)] +// CHECK:STDOUT: %.loc4_31.2: type = assoc_entity_type @I.%I.type (%I.type.2), @I.%F.type (%F.type) [symbolic = %.loc4_31.2 (constants.%.1)] +// CHECK:STDOUT: %.loc4_31.3: @I.%.loc4_31.2 (%.1) = assoc_entity element0, %F.decl [symbolic = %.loc4_31.3 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)] +// CHECK:STDOUT: %F.decl: @I.%F.type (%F.type) = fn_decl @F [symbolic = @I.%F (constants.%F)] {} {} +// CHECK:STDOUT: %.loc4_31.1: @I.%.loc4_31.2 (%.1) = assoc_entity element0, %F.decl [symbolic = %.loc4_31.3 (constants.%.2)] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = %Self.1 +// CHECK:STDOUT: .F = %.loc4_31.1 +// CHECK:STDOUT: witness = (%F.decl) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(%T.loc5_9.1: type) { +// CHECK:STDOUT: %T.loc5_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc5_9.2 (constants.%T)] +// CHECK:STDOUT: %T.patt.loc5_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc5_9.2 (constants.%T.patt)] +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: %.loc5: = complete_type_witness %.3 [template = constants.%.4] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%C.2 +// CHECK:STDOUT: complete_type_witness = %.loc5 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @X { +// CHECK:STDOUT: %.loc7: = complete_type_witness %.3 [template = constants.%.4] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%X +// CHECK:STDOUT: complete_type_witness = %.loc7 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F(@I.%T.loc4_13.1: type, @I.%Self.1: @I.%I.type (%I.type.2)) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%T) { +// CHECK:STDOUT: %T.loc4_13.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F(constants.%T, constants.%Self) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(%T.loc4_13.2) { +// CHECK:STDOUT: %T.loc4_13.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc4_13.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%T) { +// CHECK:STDOUT: %T.loc5_9.2 => constants.%T +// CHECK:STDOUT: %T.patt.loc5_9.2 => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- impl_in_interface_args.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %InInterfaceArgs: type = class_type @InInterfaceArgs [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %X: type = class_type @X [template] +// CHECK:STDOUT: %I.type.1: type = generic_interface_type @I [template] +// CHECK:STDOUT: %I: %I.type.1 = struct_value () [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %I.type.2: type = facet_type <@I, @I(%T)> [symbolic] +// CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @I(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = assoc_entity_type %I.type.2, %F.type.1 [symbolic] +// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.9 [symbolic] +// CHECK:STDOUT: %I.type.3: type = facet_type <@I, @I(%InInterfaceArgs)> [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.1, @I(%InInterfaceArgs) [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.5: type = assoc_entity_type %I.type.3, %F.type.3 [template] +// CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.9 [template] +// CHECK:STDOUT: %.7: %I.type.2 = facet_value %X, %X [symbolic] +// CHECK:STDOUT: %.8: = interface_witness (%F.2) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: %I.type.1 = import_ref Main//types, inst+7, loaded [template = constants.%I] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//types, inst+32, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//types, inst+41, loaded [template = constants.%X] +// CHECK:STDOUT: %import_ref.4: = import_ref Main//types, inst+43, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//types, inst+42, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//types, inst+14, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//types, inst+20, unloaded +// CHECK:STDOUT: %import_ref.8: @I.%F.type (%F.type.1) = import_ref Main//types, inst+16, loaded [symbolic = @I.%F (constants.%F.1)] +// CHECK:STDOUT: %import_ref.9 = import_ref Main//types, inst+16, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = imports.%import_ref.1 +// CHECK:STDOUT: .C = imports.%import_ref.2 +// CHECK:STDOUT: .X = imports.%import_ref.3 +// CHECK:STDOUT: .InInterfaceArgs = %InInterfaceArgs.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: %InInterfaceArgs.decl: type = class_decl @InInterfaceArgs [template = constants.%InInterfaceArgs] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %X.ref: type = name_ref X, imports.%import_ref.3 [template = constants.%X] +// CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, imports.%import_ref.1 [template = constants.%I] +// CHECK:STDOUT: %InInterfaceArgs.ref: type = name_ref InInterfaceArgs, file.%InInterfaceArgs.decl [template = constants.%InInterfaceArgs] +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%InInterfaceArgs)> [template = constants.%I.type.3] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @I(constants.%T: type) { +// 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: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.2)] +// CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.1)] +// CHECK:STDOUT: %F: @I.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %.1: type = assoc_entity_type @I.%I.type (%I.type.2), @I.%F.type (%F.type.1) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %.2: @I.%.1 (%.3) = assoc_entity element0, imports.%import_ref.9 [symbolic = %.2 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .F = imports.%import_ref.7 +// CHECK:STDOUT: witness = (imports.%import_ref.8) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %X.ref as %I.type { +// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {} +// CHECK:STDOUT: %.loc7: = interface_witness (%F.decl) [template = constants.%.8] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: witness = %.loc7 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @InInterfaceArgs { +// CHECK:STDOUT: %.loc5: = complete_type_witness %.1 [template = constants.%.2] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%InInterfaceArgs +// CHECK:STDOUT: complete_type_witness = %.loc5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @X { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%T: type, constants.%Self.1: @I.%I.type (%I.type.2)) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%InInterfaceArgs) { +// CHECK:STDOUT: %T => constants.%InInterfaceArgs +// CHECK:STDOUT: %T.patt => constants.%InInterfaceArgs +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type => constants.%I.type.3 +// CHECK:STDOUT: %Self => constants.%Self.2 +// CHECK:STDOUT: %F.type => constants.%F.type.3 +// CHECK:STDOUT: %F => constants.%F.3 +// CHECK:STDOUT: %.1 => constants.%.5 +// CHECK:STDOUT: %.2 => constants.%.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%InInterfaceArgs, constants.%.7) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- use_impl_in_interface_args.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %X: type = class_type @X [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// 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: %I.type.1: type = generic_interface_type @I [template] +// CHECK:STDOUT: %I: %I.type.1 = struct_value () [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %I.type.2: type = facet_type <@I, @I(%T)> [symbolic] +// CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @I(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.4: type = assoc_entity_type %I.type.2, %F.type.1 [symbolic] +// CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.10 [symbolic] +// CHECK:STDOUT: %InInterfaceArgs: type = class_type @InInterfaceArgs [template] +// CHECK:STDOUT: %I.type.3: type = facet_type <@I, @I(%InInterfaceArgs)> [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @I(%InInterfaceArgs) [template] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %.6: type = assoc_entity_type %I.type.3, %F.type.2 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.10 [template] +// CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.13 [symbolic] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.9: = interface_witness (%F.3) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: %I.type.1 = import_ref Main//types, inst+7, loaded [template = constants.%I] +// CHECK:STDOUT: %import_ref.2 = import_ref Main//types, inst+32, unloaded +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//types, inst+41, loaded [template = constants.%X] +// CHECK:STDOUT: %import_ref.4: type = import_ref Main//impl_in_interface_args, inst+5, loaded [template = constants.%InInterfaceArgs] +// CHECK:STDOUT: %import_ref.5: = import_ref Main//types, inst+43, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.6 = import_ref Main//types, inst+42, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//types, inst+14, unloaded +// CHECK:STDOUT: %import_ref.8: @I.%.1 (%.4) = import_ref Main//types, inst+20, loaded [symbolic = @I.%.2 (constants.%.8)] +// CHECK:STDOUT: %import_ref.9 = import_ref Main//types, inst+16, unloaded +// CHECK:STDOUT: %import_ref.10 = import_ref Main//types, inst+16, unloaded +// CHECK:STDOUT: %import_ref.11: = import_ref Main//impl_in_interface_args, inst+8, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.12 = import_ref Main//impl_in_interface_args, inst+6, unloaded +// CHECK:STDOUT: %import_ref.14: type = import_ref Main//impl_in_interface_args, inst+14, loaded [template = constants.%X] +// CHECK:STDOUT: %import_ref.15: type = import_ref Main//impl_in_interface_args, inst+45, loaded [template = constants.%I.type.3] +// CHECK:STDOUT: %import_ref.16: = import_ref Main//impl_in_interface_args, inst+56, loaded [template = constants.%.9] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = imports.%import_ref.1 +// CHECK:STDOUT: .C = imports.%import_ref.2 +// CHECK:STDOUT: .X = imports.%import_ref.3 +// CHECK:STDOUT: .InInterfaceArgs = imports.%import_ref.4 +// CHECK:STDOUT: .G = %G.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] { +// CHECK:STDOUT: %x.patt: %X = binding_pattern x +// CHECK:STDOUT: %x.param_patt: %X = value_param_pattern %x.patt, runtime_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %X.ref: type = name_ref X, imports.%import_ref.3 [template = constants.%X] +// CHECK:STDOUT: %x.param: %X = value_param runtime_param0 +// CHECK:STDOUT: %x: %X = bind_name x, %x.param +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @I(constants.%T: type) { +// 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: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.2)] +// CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.1)] +// CHECK:STDOUT: %F: @I.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %.1: type = assoc_entity_type @I.%I.type (%I.type.2), @I.%F.type (%F.type.1) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: %.2: @I.%.1 (%.4) = assoc_entity element0, imports.%import_ref.10 [symbolic = %.2 (constants.%.5)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.7 +// CHECK:STDOUT: .F = imports.%import_ref.8 +// CHECK:STDOUT: witness = (imports.%import_ref.9) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: imports.%import_ref.14 as imports.%import_ref.15 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.16 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @X { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @InInterfaceArgs { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.12 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.11 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @G(%x.param_patt: %X) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %x.ref: %X = name_ref x, %x +// CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, imports.%import_ref.1 [template = constants.%I] +// CHECK:STDOUT: %InInterfaceArgs.ref: type = name_ref InInterfaceArgs, imports.%import_ref.4 [template = constants.%InInterfaceArgs] +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%InInterfaceArgs)> [template = constants.%I.type.3] +// CHECK:STDOUT: %.loc6_35: %.6 = specific_constant imports.%import_ref.8, @I(constants.%InInterfaceArgs) [template = constants.%.7] +// CHECK:STDOUT: %F.ref: %.6 = name_ref F, %.loc6_35 [template = constants.%.7] +// CHECK:STDOUT: %.loc6_15: %F.type.2 = interface_witness_access constants.%.9, element0 [template = constants.%F.3] +// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc6_15() +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%T: type, constants.%Self.1: @I.%I.type (%I.type.2)) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%InInterfaceArgs) { +// CHECK:STDOUT: %T => constants.%InInterfaceArgs +// CHECK:STDOUT: %T.patt => constants.%InInterfaceArgs +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type => constants.%I.type.3 +// CHECK:STDOUT: %Self => constants.%Self.2 +// CHECK:STDOUT: %F.type => constants.%F.type.2 +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: %.1 => constants.%.6 +// CHECK:STDOUT: %.2 => constants.%.7 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: --- impl_in_class_args.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %InClassArgs: type = class_type @InClassArgs [template] +// CHECK:STDOUT: %.1: type = struct_type {} [template] +// CHECK:STDOUT: %.2: = complete_type_witness %.1 [template] +// CHECK:STDOUT: %C.type: type = generic_class_type @C [template] +// CHECK:STDOUT: %C.1: %C.type = struct_value () [template] +// CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] +// CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%InClassArgs) [template] +// CHECK:STDOUT: %I.type.1: type = generic_interface_type @I [template] +// CHECK:STDOUT: %I: %I.type.1 = struct_value () [template] +// CHECK:STDOUT: %I.type.2: type = facet_type <@I, @I(%T)> [symbolic] +// CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @I(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.3: type = assoc_entity_type %I.type.2, %F.type.1 [symbolic] +// CHECK:STDOUT: %.4: %.3 = assoc_entity element0, imports.%import_ref.9 [symbolic] +// CHECK:STDOUT: %X: type = class_type @X [template] +// CHECK:STDOUT: %I.type.3: type = facet_type <@I, @I(%X)> [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.1, @I(%X) [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.5: type = assoc_entity_type %I.type.3, %F.type.3 [template] +// CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.9 [template] +// CHECK:STDOUT: %.7: %I.type.2 = facet_value %C.3, %C.3 [symbolic] +// CHECK:STDOUT: %.8: = interface_witness (%F.2) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: %I.type.1 = import_ref Main//types, inst+7, loaded [template = constants.%I] +// CHECK:STDOUT: %import_ref.2: %C.type = import_ref Main//types, inst+32, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//types, inst+41, loaded [template = constants.%X] +// CHECK:STDOUT: %import_ref.4: = import_ref Main//types, inst+39, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.5 = import_ref Main//types, inst+37, unloaded +// CHECK:STDOUT: %import_ref.6 = import_ref Main//types, inst+14, unloaded +// CHECK:STDOUT: %import_ref.7 = import_ref Main//types, inst+20, unloaded +// CHECK:STDOUT: %import_ref.8: @I.%F.type (%F.type.1) = import_ref Main//types, inst+16, loaded [symbolic = @I.%F (constants.%F.1)] +// CHECK:STDOUT: %import_ref.9 = import_ref Main//types, inst+16, unloaded +// CHECK:STDOUT: %import_ref.10: = import_ref Main//types, inst+43, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.11 = import_ref Main//types, inst+42, unloaded +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = imports.%import_ref.1 +// CHECK:STDOUT: .C = imports.%import_ref.2 +// CHECK:STDOUT: .X = imports.%import_ref.3 +// CHECK:STDOUT: .InClassArgs = %InClassArgs.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: %InClassArgs.decl: type = class_decl @InClassArgs [template = constants.%InClassArgs] {} {} +// CHECK:STDOUT: impl_decl @impl [template] {} { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.2 [template = constants.%C.1] +// CHECK:STDOUT: %InClassArgs.ref: type = name_ref InClassArgs, file.%InClassArgs.decl [template = constants.%InClassArgs] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%InClassArgs) [template = constants.%C.3] +// CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, imports.%import_ref.1 [template = constants.%I] +// CHECK:STDOUT: %X.ref: type = name_ref X, imports.%import_ref.3 [template = constants.%X] +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%X)> [template = constants.%I.type.3] +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @I(constants.%T: type) { +// 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: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.2)] +// CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.1)] +// CHECK:STDOUT: %F: @I.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %.1: type = assoc_entity_type @I.%I.type (%I.type.2), @I.%F.type (%F.type.1) [symbolic = %.1 (constants.%.3)] +// CHECK:STDOUT: %.2: @I.%.1 (%.3) = assoc_entity element0, imports.%import_ref.9 [symbolic = %.2 (constants.%.4)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: .F = imports.%import_ref.7 +// CHECK:STDOUT: witness = (imports.%import_ref.8) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: %C as %I.type { +// CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {} +// CHECK:STDOUT: %.loc7: = interface_witness (%F.decl) [template = constants.%.8] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .F = %F.decl +// CHECK:STDOUT: witness = %.loc7 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @InClassArgs { +// CHECK:STDOUT: %.loc5: = complete_type_witness %.1 [template = constants.%.2] +// CHECK:STDOUT: +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = constants.%InClassArgs +// CHECK:STDOUT: complete_type_witness = %.loc5 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(constants.%T: type) { +// 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: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.5 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.4 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @X { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.11 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.10 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%T: type, constants.%Self.1: @I.%I.type (%I.type.2)) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2() { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%InClassArgs) { +// CHECK:STDOUT: %T => constants.%InClassArgs +// CHECK:STDOUT: %T.patt => constants.%InClassArgs +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%X) { +// CHECK:STDOUT: %T => constants.%X +// CHECK:STDOUT: %T.patt => constants.%X +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type => constants.%I.type.3 +// CHECK:STDOUT: %Self => constants.%Self.2 +// CHECK:STDOUT: %F.type => constants.%F.type.3 +// CHECK:STDOUT: %F => constants.%F.3 +// CHECK:STDOUT: %.1 => constants.%.5 +// CHECK:STDOUT: %.2 => constants.%.6 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%X, constants.%.7) {} +// CHECK:STDOUT: +// CHECK:STDOUT: --- use_impl_in_class_args.carbon +// CHECK:STDOUT: +// CHECK:STDOUT: constants { +// CHECK:STDOUT: %C.type: type = generic_class_type @C [template] +// CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [template] +// CHECK:STDOUT: %C.1: %C.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: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] +// CHECK:STDOUT: %InClassArgs: type = class_type @InClassArgs [template] +// CHECK:STDOUT: %C.3: type = class_type @C, @C(%InClassArgs) [template] +// CHECK:STDOUT: %H.type: type = fn_type @H [template] +// CHECK:STDOUT: %H: %H.type = struct_value () [template] +// CHECK:STDOUT: %I.type.1: type = generic_interface_type @I [template] +// CHECK:STDOUT: %I: %I.type.1 = struct_value () [template] +// CHECK:STDOUT: %I.type.2: type = facet_type <@I, @I(%T)> [symbolic] +// CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic] +// CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @I(%T) [symbolic] +// CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] +// CHECK:STDOUT: %.4: type = assoc_entity_type %I.type.2, %F.type.1 [symbolic] +// CHECK:STDOUT: %.5: %.4 = assoc_entity element0, imports.%import_ref.12 [symbolic] +// CHECK:STDOUT: %X: type = class_type @X [template] +// CHECK:STDOUT: %I.type.3: type = facet_type <@I, @I(%X)> [template] +// CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @I(%X) [template] +// CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] +// CHECK:STDOUT: %.6: type = assoc_entity_type %I.type.3, %F.type.2 [template] +// CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.12 [template] +// CHECK:STDOUT: %.8: %.4 = assoc_entity element0, imports.%import_ref.15 [symbolic] +// CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template] +// CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] +// CHECK:STDOUT: %.9: = interface_witness (%F.3) [template] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: imports { +// CHECK:STDOUT: %import_ref.1: %I.type.1 = import_ref Main//types, inst+7, loaded [template = constants.%I] +// CHECK:STDOUT: %import_ref.2: %C.type = import_ref Main//types, inst+32, loaded [template = constants.%C.1] +// CHECK:STDOUT: %import_ref.3: type = import_ref Main//types, inst+41, loaded [template = constants.%X] +// CHECK:STDOUT: %import_ref.4: type = import_ref Main//impl_in_class_args, inst+5, loaded [template = constants.%InClassArgs] +// CHECK:STDOUT: %import_ref.5: = import_ref Main//types, inst+39, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.6 = import_ref Main//types, inst+37, unloaded +// CHECK:STDOUT: %import_ref.7: = import_ref Main//impl_in_class_args, inst+8, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.8 = import_ref Main//impl_in_class_args, inst+6, unloaded +// CHECK:STDOUT: %import_ref.9 = import_ref Main//types, inst+14, unloaded +// CHECK:STDOUT: %import_ref.10: @I.%.1 (%.4) = import_ref Main//types, inst+20, loaded [symbolic = @I.%.2 (constants.%.8)] +// CHECK:STDOUT: %import_ref.11 = import_ref Main//types, inst+16, unloaded +// CHECK:STDOUT: %import_ref.12 = import_ref Main//types, inst+16, unloaded +// CHECK:STDOUT: %import_ref.13: = import_ref Main//types, inst+43, loaded [template = constants.%.2] +// CHECK:STDOUT: %import_ref.14 = import_ref Main//types, inst+42, unloaded +// CHECK:STDOUT: %import_ref.16: type = import_ref Main//impl_in_class_args, inst+25, loaded [template = constants.%C.3] +// CHECK:STDOUT: %import_ref.17: type = import_ref Main//impl_in_class_args, inst+58, loaded [template = constants.%I.type.3] +// CHECK:STDOUT: %import_ref.18: = import_ref Main//impl_in_class_args, inst+69, loaded [template = constants.%.9] +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: file { +// CHECK:STDOUT: package: = namespace [template] { +// CHECK:STDOUT: .I = imports.%import_ref.1 +// CHECK:STDOUT: .C = imports.%import_ref.2 +// CHECK:STDOUT: .X = imports.%import_ref.3 +// CHECK:STDOUT: .InClassArgs = imports.%import_ref.4 +// CHECK:STDOUT: .H = %H.decl +// CHECK:STDOUT: } +// CHECK:STDOUT: %default.import = import +// CHECK:STDOUT: %H.decl: %H.type = fn_decl @H [template = constants.%H] { +// CHECK:STDOUT: %c.patt: %C.3 = binding_pattern c +// CHECK:STDOUT: %c.param_patt: %C.3 = value_param_pattern %c.patt, runtime_param0 +// CHECK:STDOUT: } { +// CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%import_ref.2 [template = constants.%C.1] +// CHECK:STDOUT: %InClassArgs.ref: type = name_ref InClassArgs, imports.%import_ref.4 [template = constants.%InClassArgs] +// CHECK:STDOUT: %C: type = class_type @C, @C(constants.%InClassArgs) [template = constants.%C.3] +// CHECK:STDOUT: %c.param: %C.3 = value_param runtime_param0 +// CHECK:STDOUT: %c: %C.3 = bind_name c, %c.param +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic interface @I(constants.%T: type) { +// 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: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(%T)> [symbolic = %I.type (constants.%I.type.2)] +// CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)] +// CHECK:STDOUT: %F.type: type = fn_type @F.1, @I(%T) [symbolic = %F.type (constants.%F.type.1)] +// CHECK:STDOUT: %F: @I.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] +// CHECK:STDOUT: %.1: type = assoc_entity_type @I.%I.type (%I.type.2), @I.%F.type (%F.type.1) [symbolic = %.1 (constants.%.4)] +// CHECK:STDOUT: %.2: @I.%.1 (%.4) = assoc_entity element0, imports.%import_ref.12 [symbolic = %.2 (constants.%.5)] +// CHECK:STDOUT: +// CHECK:STDOUT: interface { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.9 +// CHECK:STDOUT: .F = imports.%import_ref.10 +// CHECK:STDOUT: witness = (imports.%import_ref.11) +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: impl @impl: imports.%import_ref.16 as imports.%import_ref.17 { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: witness = imports.%import_ref.18 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic class @C(constants.%T: type) { +// 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: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: +// CHECK:STDOUT: class { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.6 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.5 +// CHECK:STDOUT: } +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @InClassArgs { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.8 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.7 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: class @X { +// CHECK:STDOUT: !members: +// CHECK:STDOUT: .Self = imports.%import_ref.14 +// CHECK:STDOUT: complete_type_witness = imports.%import_ref.13 +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @H(%c.param_patt: %C.3) { +// CHECK:STDOUT: !entry: +// CHECK:STDOUT: %c.ref: %C.3 = name_ref c, %c +// CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, imports.%import_ref.1 [template = constants.%I] +// CHECK:STDOUT: %X.ref: type = name_ref X, imports.%import_ref.3 [template = constants.%X] +// CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%X)> [template = constants.%I.type.3] +// CHECK:STDOUT: %.loc6_34: %.6 = specific_constant imports.%import_ref.10, @I(constants.%X) [template = constants.%.7] +// CHECK:STDOUT: %F.ref: %.6 = name_ref F, %.loc6_34 [template = constants.%.7] +// CHECK:STDOUT: %.loc6_28: %F.type.2 = interface_witness_access constants.%.9, element0 [template = constants.%F.3] +// CHECK:STDOUT: %F.call: init %empty_tuple.type = call %.loc6_28() +// CHECK:STDOUT: return +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: generic fn @F.1(constants.%T: type, constants.%Self.1: @I.%I.type (%I.type.2)) { +// CHECK:STDOUT: +// CHECK:STDOUT: fn(); +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: fn @F.2(); +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @C(constants.%InClassArgs) { +// CHECK:STDOUT: %T => constants.%InClassArgs +// CHECK:STDOUT: %T.patt => constants.%InClassArgs +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(%T) { +// CHECK:STDOUT: %T => constants.%T +// CHECK:STDOUT: %T.patt => constants.%T +// CHECK:STDOUT: } +// CHECK:STDOUT: +// CHECK:STDOUT: specific @F.1(constants.%T, constants.%Self.1) {} +// CHECK:STDOUT: +// CHECK:STDOUT: specific @I(constants.%X) { +// CHECK:STDOUT: %T => constants.%X +// CHECK:STDOUT: %T.patt => constants.%X +// CHECK:STDOUT: +// CHECK:STDOUT: !definition: +// CHECK:STDOUT: %I.type => constants.%I.type.3 +// CHECK:STDOUT: %Self => constants.%Self.2 +// CHECK:STDOUT: %F.type => constants.%F.type.2 +// CHECK:STDOUT: %F => constants.%F.2 +// CHECK:STDOUT: %.1 => constants.%.6 +// CHECK:STDOUT: %.2 => constants.%.7 +// CHECK:STDOUT: } +// CHECK:STDOUT: