// 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/class/generic/import.carbon // TIP: To dump output, run: // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/import.carbon // --- foo.carbon library "[[@TEST_NAME]]"; class Class(T:! type); class CompleteClass(T:! type) { var n: i32; fn F() -> i32 { return 0; } } fn F() -> CompleteClass(i32); // --- foo.impl.carbon impl library "[[@TEST_NAME]]"; class Class(T:! type) { var x: T; } fn F() -> CompleteClass(i32) { return {.n = 1}; } // --- use_foo.carbon library "[[@TEST_NAME]]"; import library "foo"; fn UseMethod() -> i32 { var v: CompleteClass(i32) = F(); return v.F(); } fn UseField() -> i32 { var v: CompleteClass(i32) = F(); return v.n; } // --- fail_generic_arg_mismatch.carbon library "[[@TEST_NAME]]"; import library "foo"; fn Use() { // TODO: Include the generic arguments in the formatted type name. // CHECK:STDERR: fail_generic_arg_mismatch.carbon:[[@LINE+7]]:3: error: cannot implicitly convert from `CompleteClass` to `CompleteClass` [ImplicitAsConversionFailure] // CHECK:STDERR: var v: CompleteClass(i32*) = F(); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: fail_generic_arg_mismatch.carbon:[[@LINE+4]]:3: note: type `CompleteClass` does not implement interface `ImplicitAs` [MissingImplInMemberAccessNote] // CHECK:STDERR: var v: CompleteClass(i32*) = F(); // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // CHECK:STDERR: var v: CompleteClass(i32*) = F(); } // --- fail_foo.impl.carbon impl library "[[@TEST_NAME]]"; // CHECK:STDERR: fail_foo.impl.carbon:[[@LINE+8]]:13: error: redeclaration differs at parameter 1 [RedeclParamDiffers] // CHECK:STDERR: class Class(U:! type) { // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: fail_foo.impl.carbon:[[@LINE-5]]:6: in import [InImport] // CHECK:STDERR: foo.carbon:4:13: note: previous declaration's corresponding parameter here [RedeclParamPrevious] // CHECK:STDERR: class Class(T:! type); // CHECK:STDERR: ^~~~~~~~ // CHECK:STDERR: class Class(U:! type) { // CHECK:STDERR: fail_foo.impl.carbon:[[@LINE+3]]:10: error: name `T` not found [NameNotFound] // CHECK:STDERR: var x: T; // CHECK:STDERR: ^ var x: T; } // CHECK:STDOUT: --- foo.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %T.patt.1: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] // CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %T.patt.2: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] // CHECK:STDOUT: %.2: type = unbound_element_type %CompleteClass.2, i32 [symbolic] // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] // CHECK:STDOUT: %.3: type = struct_type {.n: i32} [template] // CHECK:STDOUT: %.4: = complete_type_witness %.3 [template] // CHECK:STDOUT: %.5: i32 = int_value 0 [template] // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template] // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .Int32 = %import_ref // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .CompleteClass = %CompleteClass.decl // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.patt.loc4_13.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc4_13.2 (constants.%T.patt.1)] // 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.1)] // 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: %CompleteClass.decl: %CompleteClass.type = class_decl @CompleteClass [template = constants.%CompleteClass.1] { // CHECK:STDOUT: %T.patt.loc6_21.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_21.2 (constants.%T.patt.2)] // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc6_21.1, runtime_param [symbolic = %T.patt.loc6_21.2 (constants.%T.patt.2)] // CHECK:STDOUT: } { // CHECK:STDOUT: %T.param: type = value_param runtime_param // CHECK:STDOUT: %T.loc6_21.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc6_21.2 (constants.%T)] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { // CHECK:STDOUT: %return.patt: %CompleteClass.3 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %CompleteClass.3 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, file.%CompleteClass.decl [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_24.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc11_24.2: type = converted %int.make_type_32, %.loc11_24.1 [template = i32] // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(i32) [template = constants.%CompleteClass.3] // CHECK:STDOUT: %return.param: ref %CompleteClass.3 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %CompleteClass.3 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @Class(%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.1)] // CHECK:STDOUT: // CHECK:STDOUT: class; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @CompleteClass(%T.loc6_21.1: type) { // CHECK:STDOUT: %T.loc6_21.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_21.2 (constants.%T)] // CHECK:STDOUT: %T.patt.loc6_21.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_21.2 (constants.%T.patt.2)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T.loc6_21.2) [symbolic = %CompleteClass (constants.%CompleteClass.2)] // CHECK:STDOUT: %.loc7_8.2: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.loc7_8.2 (constants.%.2)] // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T.loc6_21.2) [symbolic = %F.type (constants.%F.type.1)] // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32, %.loc7_10.1 [template = i32] // CHECK:STDOUT: %.loc7_8.1: @CompleteClass.%.loc7_8.2 (%.2) = field_decl n, element0 [template] // CHECK:STDOUT: %F.decl: @CompleteClass.%F.type (%F.type.1) = fn_decl @F.1 [symbolic = @CompleteClass.%F (constants.%F.1)] { // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32, %.loc8_13.1 [template = i32] // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %.loc9: = complete_type_witness %.3 [template = constants.%.4] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%CompleteClass.2 // CHECK:STDOUT: .n = %.loc7_8.1 // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: // CHECK:STDOUT: generic fn @F.1(@CompleteClass.%T.loc6_21.1: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: // CHECK:STDOUT: fn() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc8_26: i32 = int_value 0 [template = constants.%.5] // CHECK:STDOUT: return %.loc8_26 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() -> %CompleteClass.3; // CHECK:STDOUT: // CHECK:STDOUT: specific @Class(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 @CompleteClass(constants.%T) { // CHECK:STDOUT: %T.loc6_21.2 => constants.%T // CHECK:STDOUT: %T.patt.loc6_21.2 => constants.%T // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.2 // CHECK:STDOUT: %.loc7_8.2 => constants.%.2 // CHECK:STDOUT: %F.type => constants.%F.type.1 // CHECK:STDOUT: %F => constants.%F.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F.1(constants.%T) {} // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T.loc6_21.2) { // CHECK:STDOUT: %T.loc6_21.2 => constants.%T // CHECK:STDOUT: %T.patt.loc6_21.2 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(i32) { // CHECK:STDOUT: %T.loc6_21.2 => i32 // CHECK:STDOUT: %T.patt.loc6_21.2 => i32 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- foo.impl.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %T.patt.1: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] // CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %T.patt.2: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic] // CHECK:STDOUT: %.3: type = struct_type {.x: %T} [symbolic] // CHECK:STDOUT: %.4: = complete_type_witness %.3 [symbolic] // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] // CHECK:STDOUT: %.5: type = struct_type {.n: i32} [template] // CHECK:STDOUT: %.6: = complete_type_witness %.5 [template] // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %.7: type = unbound_element_type %CompleteClass.2, i32 [symbolic] // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template] // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: %.8: type = unbound_element_type %CompleteClass.3, i32 [template] // CHECK:STDOUT: %F.type.3: type = fn_type @F.1, @CompleteClass(i32) [template] // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] // CHECK:STDOUT: %.9: type = ptr_type %.5 [template] // CHECK:STDOUT: %.10: i32 = int_value 1 [template] // CHECK:STDOUT: %struct: %CompleteClass.3 = struct_value (%.10) [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref.1: %Class.type = import_ref Main//foo, inst+9, loaded [template = constants.%Class.1] // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+21, loaded [template = constants.%CompleteClass.1] // CHECK:STDOUT: %import_ref.3: %F.type.2 = import_ref Main//foo, inst+71, loaded [template = constants.%F.2] // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .Int32 = %import_ref.7 // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+26, unloaded // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+38, unloaded // CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+48, unloaded // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Class = %Class.decl // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = %F.decl // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] { // CHECK:STDOUT: %T.patt.loc4: type = symbolic_binding_pattern T, 0 [symbolic = constants.%T.patt.1] // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc4, runtime_param [symbolic = constants.%T.patt.1] // CHECK:STDOUT: } { // CHECK:STDOUT: %T.param: type = value_param runtime_param // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T, 0, %T.param [symbolic = constants.%T] // CHECK:STDOUT: } // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] { // CHECK:STDOUT: %return.patt: %CompleteClass.3 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: %CompleteClass.3 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc8_24.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc8_24.2: type = converted %int.make_type_32, %.loc8_24.1 [template = i32] // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(i32) [template = constants.%CompleteClass.3] // CHECK:STDOUT: %return.param: ref %CompleteClass.3 = out_param runtime_param0 // CHECK:STDOUT: %return: ref %CompleteClass.3 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @Class(constants.%T: type) { // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)] // CHECK:STDOUT: %T.patt.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.1 (constants.%T.patt.2)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.1) [symbolic = %Class (constants.%Class.2)] // CHECK:STDOUT: %.loc5_8.2: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T.1 (%T) [symbolic = %.loc5_8.2 (constants.%.2)] // CHECK:STDOUT: %.loc6_1.2: type = struct_type {.x: @Class.%T.1 (%T)} [symbolic = %.loc6_1.2 (constants.%.3)] // CHECK:STDOUT: %.loc6_1.3: = complete_type_witness @Class.%.loc6_1.2 (%.3) [symbolic = %.loc6_1.3 (constants.%.4)] // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4 [symbolic = %T.1 (constants.%T)] // CHECK:STDOUT: %.loc5_8.1: @Class.%.loc5_8.2 (%.2) = field_decl x, element0 [template] // CHECK:STDOUT: %.loc6_1.1: = complete_type_witness %.3 [symbolic = %.loc6_1.3 (constants.%.4)] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%Class.2 // CHECK:STDOUT: .x = %.loc5_8.1 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @CompleteClass(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.2)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)] // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.7)] // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)] // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = imports.%import_ref.4 // CHECK:STDOUT: .n = imports.%import_ref.5 // CHECK:STDOUT: .F = imports.%import_ref.6 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @F.1(constants.%T: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: // CHECK:STDOUT: fn() -> i32; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() -> %return: %CompleteClass.3 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %.loc9_16: i32 = int_value 1 [template = constants.%.10] // CHECK:STDOUT: %.loc9_17.1: %.5 = struct_literal (%.loc9_16) // CHECK:STDOUT: %.loc9_17.2: ref i32 = class_element_access %return, element0 // CHECK:STDOUT: %.loc9_17.3: init i32 = initialize_from %.loc9_16 to %.loc9_17.2 [template = constants.%.10] // CHECK:STDOUT: %.loc9_17.4: init %CompleteClass.3 = class_init (%.loc9_17.3), %return [template = constants.%struct] // CHECK:STDOUT: %.loc9_18: init %CompleteClass.3 = converted %.loc9_17.1, %.loc9_17.4 [template = constants.%struct] // CHECK:STDOUT: return %.loc9_18 to %return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Class(constants.%T) { // CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: %T.patt.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Class(@Class.%T.1) { // CHECK:STDOUT: %T.1 => constants.%T // CHECK:STDOUT: %T.patt.1 => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(constants.%T) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.2 // CHECK:STDOUT: %.1 => constants.%.7 // CHECK:STDOUT: %F.type => constants.%F.type.1 // CHECK:STDOUT: %F => constants.%F.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F.1(constants.%T) {} // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(i32) { // CHECK:STDOUT: %T => i32 // CHECK:STDOUT: %T.patt => i32 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3 // CHECK:STDOUT: %.1 => constants.%.8 // CHECK:STDOUT: %F.type => constants.%F.type.3 // CHECK:STDOUT: %F => constants.%F.3 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- use_foo.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] // CHECK:STDOUT: %UseMethod.type: type = fn_type @UseMethod [template] // CHECK:STDOUT: %UseMethod: %UseMethod.type = struct_value () [template] // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template] // CHECK:STDOUT: %.3: = complete_type_witness %.2 [template] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %.4: type = unbound_element_type %CompleteClass.2, i32 [symbolic] // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template] // CHECK:STDOUT: %.5: type = unbound_element_type %CompleteClass.3, i32 [template] // CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @CompleteClass(i32) [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: %.6: type = ptr_type %.2 [template] // CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] // CHECK:STDOUT: %.7: = specific_function %F.2, @F.1(i32) [template] // CHECK:STDOUT: %UseField.type: type = fn_type @UseField [template] // CHECK:STDOUT: %UseField: %UseField.type = struct_value () [template] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref.1 = import_ref Main//foo, inst+9, unloaded // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+21, loaded [template = constants.%CompleteClass.1] // CHECK:STDOUT: %import_ref.3: %F.type.3 = import_ref Main//foo, inst+71, loaded [template = constants.%F.3] // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .Int32 = %import_ref.4 // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32] // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+26, unloaded // CHECK:STDOUT: %import_ref.6: @CompleteClass.%.1 (%.4) = import_ref Main//foo, inst+38, loaded [template = %.1] // CHECK:STDOUT: %import_ref.7: @CompleteClass.%F.type (%F.type.1) = import_ref Main//foo, inst+48, loaded [symbolic = @CompleteClass.%F (constants.%F.1)] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Class = imports.%import_ref.1 // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = imports.%import_ref.3 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .UseMethod = %UseMethod.decl // CHECK:STDOUT: .UseField = %UseField.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %UseMethod.decl: %UseMethod.type = fn_decl @UseMethod [template = constants.%UseMethod] { // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc5_19.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32] // CHECK:STDOUT: %.loc5_19.2: type = converted %int.make_type_32.loc5, %.loc5_19.1 [template = i32] // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: %UseField.decl: %UseField.type = fn_decl @UseField [template = constants.%UseField] { // CHECK:STDOUT: %return.patt: i32 = return_slot_pattern // CHECK:STDOUT: %return.param_patt: i32 = out_param_pattern %return.patt, runtime_param0 // CHECK:STDOUT: } { // CHECK:STDOUT: %int.make_type_32.loc10: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc10_18.1: type = value_of_initializer %int.make_type_32.loc10 [template = i32] // CHECK:STDOUT: %.loc10_18.2: type = converted %int.make_type_32.loc10, %.loc10_18.1 [template = i32] // CHECK:STDOUT: %return.param: ref i32 = out_param runtime_param0 // CHECK:STDOUT: %return: ref i32 = return_slot %return.param // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @CompleteClass(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: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)] // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.4)] // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)] // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = imports.%import_ref.5 // CHECK:STDOUT: .n = imports.%import_ref.6 // CHECK:STDOUT: .F = imports.%import_ref.7 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: // CHECK:STDOUT: fn @UseMethod() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32.loc6: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc6_23.1: type = value_of_initializer %int.make_type_32.loc6 [template = i32] // CHECK:STDOUT: %.loc6_23.2: type = converted %int.make_type_32.loc6, %.loc6_23.1 [template = i32] // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(i32) [template = constants.%CompleteClass.3] // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var // CHECK:STDOUT: %F.ref.loc6: %F.type.3 = name_ref F, imports.%import_ref.3 [template = constants.%F.3] // CHECK:STDOUT: %.loc6_7: ref %CompleteClass.3 = splice_block %v.var {} // CHECK:STDOUT: %F.call.loc6: init %CompleteClass.3 = call %F.ref.loc6() to %.loc6_7 // CHECK:STDOUT: assign %v.var, %F.call.loc6 // CHECK:STDOUT: %v.ref: ref %CompleteClass.3 = name_ref v, %v // CHECK:STDOUT: %.loc7_11.1: %F.type.2 = specific_constant imports.%import_ref.7, @CompleteClass(i32) [template = constants.%F.2] // CHECK:STDOUT: %F.ref.loc7: %F.type.2 = name_ref F, %.loc7_11.1 [template = constants.%F.2] // CHECK:STDOUT: %.loc7_11.2: = specific_function %F.ref.loc7, @F.1(i32) [template = constants.%.7] // CHECK:STDOUT: %F.call.loc7: init i32 = call %.loc7_11.2() // CHECK:STDOUT: %.loc7_15.1: i32 = value_of_initializer %F.call.loc7 // CHECK:STDOUT: %.loc7_15.2: i32 = converted %F.call.loc7, %.loc7_15.1 // CHECK:STDOUT: return %.loc7_15.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @F.1(constants.%T: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: // CHECK:STDOUT: fn() -> i32; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() -> %CompleteClass.3; // CHECK:STDOUT: // CHECK:STDOUT: fn @UseField() -> i32 { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32.loc11: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc11_23.1: type = value_of_initializer %int.make_type_32.loc11 [template = i32] // CHECK:STDOUT: %.loc11_23.2: type = converted %int.make_type_32.loc11, %.loc11_23.1 [template = i32] // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(i32) [template = constants.%CompleteClass.3] // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var // CHECK:STDOUT: %F.ref: %F.type.3 = name_ref F, imports.%import_ref.3 [template = constants.%F.3] // CHECK:STDOUT: %.loc11_7: ref %CompleteClass.3 = splice_block %v.var {} // CHECK:STDOUT: %F.call: init %CompleteClass.3 = call %F.ref() to %.loc11_7 // CHECK:STDOUT: assign %v.var, %F.call // CHECK:STDOUT: %v.ref: ref %CompleteClass.3 = name_ref v, %v // CHECK:STDOUT: %n.ref: %.5 = name_ref n, imports.%import_ref.6 [template = imports.%.1] // CHECK:STDOUT: %.loc12_11.1: ref i32 = class_element_access %v.ref, element0 // CHECK:STDOUT: %.loc12_11.2: i32 = bind_value %.loc12_11.1 // CHECK:STDOUT: return %.loc12_11.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(constants.%T) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.2 // CHECK:STDOUT: %.1 => constants.%.4 // CHECK:STDOUT: %F.type => constants.%F.type.1 // CHECK:STDOUT: %F => constants.%F.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F.1(constants.%T) {} // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(i32) { // CHECK:STDOUT: %T => i32 // CHECK:STDOUT: %T.patt => i32 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3 // CHECK:STDOUT: %.1 => constants.%.5 // CHECK:STDOUT: %F.type => constants.%F.type.2 // CHECK:STDOUT: %F => constants.%F.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F.1(i32) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_generic_arg_mismatch.carbon // CHECK:STDOUT: // CHECK:STDOUT: constants { // CHECK:STDOUT: %Use.type: type = fn_type @Use [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Use: %Use.type = struct_value () [template] // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template] // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template] // CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template] // CHECK:STDOUT: %.3: = complete_type_witness %.2 [template] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %.4: type = unbound_element_type %CompleteClass.2, i32 [symbolic] // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic] // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic] // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template] // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template] // CHECK:STDOUT: %.5: type = ptr_type i32 [template] // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(%.5) [template] // CHECK:STDOUT: %.6: type = unbound_element_type %CompleteClass.3, i32 [template] // CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @CompleteClass(%.5) [template] // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template] // CHECK:STDOUT: %.7: type = ptr_type %.2 [template] // CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template] // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template] // CHECK:STDOUT: %CompleteClass.4: type = class_type @CompleteClass, @CompleteClass(i32) [template] // CHECK:STDOUT: %.8: type = unbound_element_type %CompleteClass.4, i32 [template] // CHECK:STDOUT: %F.type.4: type = fn_type @F.1, @CompleteClass(i32) [template] // CHECK:STDOUT: %F.4: %F.type.4 = struct_value () [template] // CHECK:STDOUT: %ImplicitAs.type.1: type = generic_interface_type @ImplicitAs [template] // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type.1 = struct_value () [template] // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic] // CHECK:STDOUT: %ImplicitAs.type.2: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic] // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2) = bind_symbolic_name Self, 1 [symbolic] // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic] // CHECK:STDOUT: %Self.2: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic] // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic] // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic] // CHECK:STDOUT: %.9: type = assoc_entity_type %ImplicitAs.type.2, %Convert.type.1 [symbolic] // CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.12 [symbolic] // CHECK:STDOUT: %ImplicitAs.type.3: type = interface_type @ImplicitAs, @ImplicitAs(%CompleteClass.3) [template] // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%CompleteClass.3) [template] // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template] // CHECK:STDOUT: %.11: type = assoc_entity_type %ImplicitAs.type.3, %Convert.type.2 [template] // CHECK:STDOUT: %.12: %.11 = assoc_entity element0, imports.%import_ref.12 [template] // CHECK:STDOUT: %.13: %.9 = assoc_entity element0, imports.%import_ref.13 [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref.1 = import_ref Main//foo, inst+9, unloaded // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+21, loaded [template = constants.%CompleteClass.1] // CHECK:STDOUT: %import_ref.3: %F.type.3 = import_ref Main//foo, inst+71, loaded [template = constants.%F.3] // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: .Int32 = %import_ref.7 // CHECK:STDOUT: .ImplicitAs = %import_ref.8 // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+26, unloaded // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+38, unloaded // CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+48, unloaded // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+15, loaded [template = constants.%Int32] // CHECK:STDOUT: %import_ref.8: %ImplicitAs.type.1 = import_ref Core//prelude/operators/as, inst+49, loaded [template = constants.%ImplicitAs] // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/as, inst+55, unloaded // CHECK:STDOUT: %import_ref.10: @ImplicitAs.%.1 (%.9) = import_ref Core//prelude/operators/as, inst+77, loaded [symbolic = @ImplicitAs.%.2 (constants.%.13)] // CHECK:STDOUT: %import_ref.11 = import_ref Core//prelude/operators/as, inst+70, unloaded // CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/as, inst+70, unloaded // CHECK:STDOUT: %import_ref.13 = import_ref Core//prelude/operators/as, inst+70, unloaded // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Class = imports.%import_ref.1 // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = imports.%import_ref.3 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: .Use = %Use.decl // CHECK:STDOUT: } // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %default.import = import // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {} {} // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) { // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt (constants.%Dest.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)] // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)] // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)] // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)] // CHECK:STDOUT: %.1: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.1 (constants.%.9)] // CHECK:STDOUT: %.2: @ImplicitAs.%.1 (%.9) = assoc_entity element0, imports.%import_ref.12 [symbolic = %.2 (constants.%.10)] // CHECK:STDOUT: // CHECK:STDOUT: interface { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = imports.%import_ref.9 // CHECK:STDOUT: .Convert = imports.%import_ref.10 // CHECK:STDOUT: witness = (imports.%import_ref.11) // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @CompleteClass(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: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)] // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.4)] // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)] // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)] // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = imports.%import_ref.4 // CHECK:STDOUT: .n = imports.%import_ref.5 // CHECK:STDOUT: .F = imports.%import_ref.6 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Use() { // CHECK:STDOUT: !entry: // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1] // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32] // CHECK:STDOUT: %.loc14_27.1: type = value_of_initializer %int.make_type_32 [template = i32] // CHECK:STDOUT: %.loc14_27.2: type = converted %int.make_type_32, %.loc14_27.1 [template = i32] // CHECK:STDOUT: %.loc14_27.3: type = ptr_type i32 [template = constants.%.5] // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(constants.%.5) [template = constants.%CompleteClass.3] // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var // CHECK:STDOUT: %F.ref: %F.type.3 = name_ref F, imports.%import_ref.3 [template = constants.%F.3] // CHECK:STDOUT: %.loc14_33.1: ref %CompleteClass.4 = temporary_storage // CHECK:STDOUT: %F.call: init %CompleteClass.4 = call %F.ref() to %.loc14_33.1 // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(constants.%CompleteClass.3) [template = constants.%ImplicitAs.type.3] // CHECK:STDOUT: %.loc14_35.1: %.11 = specific_constant imports.%import_ref.10, @ImplicitAs(constants.%CompleteClass.3) [template = constants.%.12] // CHECK:STDOUT: %Convert.ref: %.11 = name_ref Convert, %.loc14_35.1 [template = constants.%.12] // CHECK:STDOUT: %.loc14_33.2: ref %CompleteClass.4 = temporary %.loc14_33.1, %F.call // CHECK:STDOUT: %.loc14_35.2: %CompleteClass.3 = converted %F.call, [template = ] // CHECK:STDOUT: assign %v.var, // CHECK:STDOUT: return // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic fn @F.1(constants.%T: type) { // CHECK:STDOUT: !definition: // CHECK:STDOUT: // CHECK:STDOUT: fn() -> i32; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32"; // CHECK:STDOUT: // CHECK:STDOUT: fn @F.2() -> %CompleteClass.4; // CHECK:STDOUT: // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.2)) { // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)] // CHECK:STDOUT: %ImplicitAs.type: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.2)] // CHECK:STDOUT: %Self: %ImplicitAs.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)] // CHECK:STDOUT: // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest); // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(constants.%T) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.2 // CHECK:STDOUT: %.1 => constants.%.4 // CHECK:STDOUT: %F.type => constants.%F.type.1 // CHECK:STDOUT: %F => constants.%F.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @F.1(constants.%T) {} // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(constants.%.5) { // CHECK:STDOUT: %T => constants.%.5 // CHECK:STDOUT: %T.patt => constants.%.5 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3 // CHECK:STDOUT: %.1 => constants.%.6 // CHECK:STDOUT: %F.type => constants.%F.type.2 // CHECK:STDOUT: %F => constants.%F.2 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @CompleteClass(i32) { // CHECK:STDOUT: %T => i32 // CHECK:STDOUT: %T.patt => i32 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.4 // CHECK:STDOUT: %.1 => constants.%.8 // CHECK:STDOUT: %F.type => constants.%F.type.4 // CHECK:STDOUT: %F => constants.%F.4 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) { // CHECK:STDOUT: %Dest => constants.%Dest // CHECK:STDOUT: %Dest.patt => constants.%Dest // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) { // CHECK:STDOUT: %Dest => constants.%Dest // CHECK:STDOUT: %Dest.patt => constants.%Dest // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) { // CHECK:STDOUT: %Dest => constants.%Dest // CHECK:STDOUT: %Dest.patt => constants.%Dest // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) { // CHECK:STDOUT: %Dest => constants.%Dest // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.2 // CHECK:STDOUT: %Self => constants.%Self.1 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @ImplicitAs(constants.%CompleteClass.3) { // CHECK:STDOUT: %Dest => constants.%CompleteClass.3 // CHECK:STDOUT: %Dest.patt => constants.%CompleteClass.3 // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.3 // CHECK:STDOUT: %Self => constants.%Self.2 // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2 // CHECK:STDOUT: %Convert => constants.%Convert.2 // CHECK:STDOUT: %.1 => constants.%.11 // CHECK:STDOUT: %.2 => constants.%.12 // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: --- fail_foo.impl.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: %Class.type: type = generic_class_type @Class [template] // CHECK:STDOUT: %.1: type = tuple_type () [template] // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template] // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic] // CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic] // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic] // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template] // CHECK:STDOUT: %.2: %.type = struct_value () [template] // CHECK:STDOUT: %.3: type = class_type @.1, @.1(%U) [symbolic] // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: imports { // CHECK:STDOUT: %import_ref.1: %Class.type = import_ref Main//foo, inst+9, loaded [template = constants.%Class.1] // CHECK:STDOUT: %import_ref.2 = import_ref Main//foo, inst+21, unloaded // CHECK:STDOUT: %import_ref.3 = import_ref Main//foo, inst+71, unloaded // CHECK:STDOUT: %Core: = namespace file.%Core.import, [template] { // CHECK:STDOUT: import Core//prelude // CHECK:STDOUT: import Core//prelude/... // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: file { // CHECK:STDOUT: package: = namespace [template] { // CHECK:STDOUT: .Class = imports.%import_ref.1 // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2 // CHECK:STDOUT: .F = imports.%import_ref.3 // CHECK:STDOUT: .Core = imports.%Core // CHECK:STDOUT: } // CHECK:STDOUT: %default.import.loc2_6.1 = import // CHECK:STDOUT: %default.import.loc2_6.2 = import // CHECK:STDOUT: %Core.import = import Core // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] { // CHECK:STDOUT: %U.patt.loc12_13.1: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc12_13.2 (constants.%U.patt)] // CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc12_13.1, runtime_param [symbolic = %U.patt.loc12_13.2 (constants.%U.patt)] // CHECK:STDOUT: } { // CHECK:STDOUT: %U.param: type = value_param runtime_param // CHECK:STDOUT: %U.loc12_13.1: type = bind_symbolic_name U, 0, %U.param [symbolic = %U.loc12_13.2 (constants.%U)] // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @Class(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: class; // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: generic class @.1(%U.loc12_13.1: type) { // CHECK:STDOUT: %U.loc12_13.2: type = bind_symbolic_name U, 0 [symbolic = %U.loc12_13.2 (constants.%U)] // CHECK:STDOUT: %U.patt.loc12_13.2: type = symbolic_binding_pattern U, 0 [symbolic = %U.patt.loc12_13.2 (constants.%U.patt)] // CHECK:STDOUT: // CHECK:STDOUT: !definition: // CHECK:STDOUT: // CHECK:STDOUT: class { // CHECK:STDOUT: %T.ref: = name_ref T, [template = ] // CHECK:STDOUT: %.loc16: = field_decl x, element0 [template] // CHECK:STDOUT: %.loc17: = complete_type_witness [template = ] // CHECK:STDOUT: // CHECK:STDOUT: !members: // CHECK:STDOUT: .Self = constants.%.3 // CHECK:STDOUT: .x = %.loc16 // CHECK:STDOUT: } // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @Class(constants.%T) { // CHECK:STDOUT: %T => constants.%T // CHECK:STDOUT: %T.patt => constants.%T // CHECK:STDOUT: } // CHECK:STDOUT: // CHECK:STDOUT: specific @.1(constants.%U) { // CHECK:STDOUT: %U.loc12_13.2 => constants.%U // CHECK:STDOUT: %U.patt.loc12_13.2 => constants.%U // CHECK:STDOUT: } // CHECK:STDOUT: