| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876 |
- // 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`
- // 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`
- // 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
- // CHECK:STDERR: class Class(U:! type) {
- // CHECK:STDERR: ^
- // CHECK:STDERR: fail_foo.impl.carbon:[[@LINE-5]]:6: in import
- // CHECK:STDERR: foo.carbon:4:13: note: previous declaration's corresponding parameter here
- // 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
- // 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: %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: %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: <witness> = complete_type_witness %.3 [template]
- // CHECK:STDOUT: %.5: i32 = int_literal 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> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int32 = %import_ref
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = 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: type = symbolic_binding_pattern T 0
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
- // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %CompleteClass.decl: %CompleteClass.type = class_decl @CompleteClass [template = constants.%CompleteClass.1] {
- // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
- // CHECK:STDOUT: %T.loc6: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {} {
- // 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: ref %CompleteClass.3 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic class @Class(%T.loc4: type) {
- // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: class;
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic class @CompleteClass(%T.loc6: type) {
- // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T.1) [symbolic = %CompleteClass (constants.%CompleteClass.2)]
- // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.2)]
- // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T.1) [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: @CompleteClass.%.1 (%.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: %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: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %.loc9: <witness> = complete_type_witness %.3 [template = constants.%.4]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%CompleteClass.2
- // CHECK:STDOUT: .n = %.loc7_8
- // 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: type) {
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn() -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %.loc8_26: i32 = int_literal 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.1 => constants.%T
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @CompleteClass(constants.%T) {
- // CHECK:STDOUT: %T.1 => constants.%T
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.2
- // CHECK:STDOUT: %.1 => 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.1) {
- // CHECK:STDOUT: %T.1 => constants.%T
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @CompleteClass(i32) {
- // CHECK:STDOUT: %T.1 => 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: %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: %.2: type = unbound_element_type %Class.2, %T [symbolic]
- // CHECK:STDOUT: %.3: type = struct_type {.x: %T} [symbolic]
- // CHECK:STDOUT: %.4: <witness> = 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: <witness> = 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_literal 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+7, loaded [template = constants.%Class.1]
- // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+16, loaded [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %import_ref.3: %F.type.2 = import_ref Main//foo, inst+57, loaded [template = constants.%F.2]
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int32 = %import_ref.7
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+20, unloaded
- // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+30, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+37, unloaded
- // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = 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 <invalid>
- // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] {
- // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
- // 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: %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: ref %CompleteClass.3 = var <return slot>
- // 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:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T.1) [symbolic = %Class (constants.%Class.2)]
- // CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T.1 (%T) [symbolic = %.1 (constants.%.2)]
- // CHECK:STDOUT: %.2: type = struct_type {.x: @Class.%T.1 (%T)} [symbolic = %.2 (constants.%.3)]
- // CHECK:STDOUT: %.3: <witness> = complete_type_witness @Class.%.2 (%.3) [symbolic = %.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: @Class.%.1 (%.2) = field_decl x, element0 [template]
- // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.3 [symbolic = %.3 (constants.%.4)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%Class.2
- // CHECK:STDOUT: .x = %.loc5
- // 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:
- // 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_literal 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: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @Class(@Class.%T.1) {
- // CHECK:STDOUT: %T.1 => constants.%T
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @CompleteClass(constants.%T) {
- // CHECK:STDOUT: %T => 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: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F.1(constants.%T) {}
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @CompleteClass(i32) {
- // CHECK:STDOUT: %T => 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: <witness> = 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: %.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: %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+7, unloaded
- // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+16, loaded [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %import_ref.3: %F.type.3 = import_ref Main//foo, inst+57, loaded [template = constants.%F.3]
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: .Int32 = %import_ref.4
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+20, unloaded
- // CHECK:STDOUT: %import_ref.6: @CompleteClass.%.1 (%.4) = import_ref Main//foo, inst+30, loaded [template = %.1]
- // CHECK:STDOUT: %import_ref.7: @CompleteClass.%F.type (%F.type.1) = import_ref Main//foo, inst+37, loaded [symbolic = @CompleteClass.%F (constants.%F.1)]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = 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 <invalid>
- // CHECK:STDOUT: %UseMethod.decl: %UseMethod.type = fn_decl @UseMethod [template = constants.%UseMethod] {} {
- // 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: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %UseField.decl: %UseField.type = fn_decl @UseField [template = constants.%UseField] {} {
- // 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: ref i32 = var <return slot>
- // 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:
- // 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: %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 [template = constants.%F.2]
- // CHECK:STDOUT: %F.call.loc7: init i32 = call %F.ref.loc7()
- // 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:
- // 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: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F.1(constants.%T) {}
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @CompleteClass(i32) {
- // CHECK:STDOUT: %T => 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:
- // 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: <witness> = 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: %.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: type = generic_interface_type @ImplicitAs [template]
- // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type = struct_value () [template]
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic]
- // CHECK:STDOUT: %.9: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
- // CHECK:STDOUT: %Self.1: @ImplicitAs.%.1 (%.9) = bind_symbolic_name Self 1 [symbolic]
- // CHECK:STDOUT: %Self.2: %.9 = 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: %.10: type = assoc_entity_type %.9, %Convert.type.1 [symbolic]
- // CHECK:STDOUT: %.11: %.10 = assoc_entity element0, imports.%import_ref.12 [symbolic]
- // CHECK:STDOUT: %.12: 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: %.13: type = assoc_entity_type %.12, %Convert.type.2 [template]
- // CHECK:STDOUT: %.14: %.13 = assoc_entity element0, imports.%import_ref.12 [template]
- // CHECK:STDOUT: %.15: %.10 = 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+7, unloaded
- // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+16, loaded [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %import_ref.3: %F.type.3 = import_ref Main//foo, inst+57, loaded [template = constants.%F.3]
- // CHECK:STDOUT: %Core: <namespace> = 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/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+20, unloaded
- // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+30, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+37, unloaded
- // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %import_ref.8: %ImplicitAs.type = import_ref Core//prelude/operators/as, inst+40, loaded [template = constants.%ImplicitAs]
- // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/as, inst+45, unloaded
- // CHECK:STDOUT: %import_ref.10: @ImplicitAs.%.2 (%.10) = import_ref Core//prelude/operators/as, inst+63, loaded [symbolic = @ImplicitAs.%.3 (constants.%.15)]
- // CHECK:STDOUT: %import_ref.11 = import_ref Core//prelude/operators/as, inst+56, unloaded
- // CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/as, inst+56, unloaded
- // CHECK:STDOUT: %import_ref.13 = import_ref Core//prelude/operators/as, inst+56, unloaded
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = 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 <invalid>
- // 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:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.9)]
- // CHECK:STDOUT: %Self: %.9 = 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: %.2: type = assoc_entity_type @ImplicitAs.%.1 (%.9), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.2 (constants.%.10)]
- // CHECK:STDOUT: %.3: @ImplicitAs.%.2 (%.10) = assoc_entity element0, imports.%import_ref.12 [symbolic = %.3 (constants.%.11)]
- // 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:
- // 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: %.loc14_35.1: type = interface_type @ImplicitAs, @ImplicitAs(constants.%CompleteClass.3) [template = constants.%.12]
- // CHECK:STDOUT: %.loc14_35.2: %.13 = specific_constant imports.%import_ref.10, @ImplicitAs(constants.%CompleteClass.3) [template = constants.%.14]
- // CHECK:STDOUT: %Convert.ref: %.13 = name_ref Convert, %.loc14_35.2 [template = constants.%.14]
- // CHECK:STDOUT: %.loc14_33.2: ref %CompleteClass.4 = temporary %.loc14_33.1, %F.call
- // CHECK:STDOUT: %.loc14_35.3: %CompleteClass.3 = converted %F.call, <error> [template = <error>]
- // CHECK:STDOUT: assign %v.var, <error>
- // 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.%.1 (%.9)) {
- // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
- // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.9)]
- // CHECK:STDOUT: %Self: %.9 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.2)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn[%self: @Convert.%Self (%Self.2)]() -> @Convert.%Dest (%Dest);
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @CompleteClass(constants.%T) {
- // CHECK:STDOUT: %T => 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: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @F.1(constants.%T) {}
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @CompleteClass(constants.%.5) {
- // CHECK:STDOUT: %T => 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:
- // 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: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.1) {
- // CHECK:STDOUT: %Dest => constants.%Dest
- // CHECK:STDOUT: %.1 => constants.%.9
- // 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:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT: %.1 => constants.%.12
- // CHECK:STDOUT: %Self => constants.%Self.2
- // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
- // CHECK:STDOUT: %Convert => constants.%Convert.2
- // CHECK:STDOUT: %.2 => constants.%.13
- // CHECK:STDOUT: %.3 => constants.%.14
- // 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: %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: %.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+7, loaded [template = constants.%Class.1]
- // CHECK:STDOUT: %import_ref.2 = import_ref Main//foo, inst+16, unloaded
- // CHECK:STDOUT: %import_ref.3 = import_ref Main//foo, inst+57, unloaded
- // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
- // CHECK:STDOUT: import Core//prelude
- // CHECK:STDOUT: import Core//prelude/operators
- // CHECK:STDOUT: import Core//prelude/types
- // CHECK:STDOUT: import Core//prelude/operators/arithmetic
- // CHECK:STDOUT: import Core//prelude/operators/as
- // CHECK:STDOUT: import Core//prelude/operators/bitwise
- // CHECK:STDOUT: import Core//prelude/operators/comparison
- // CHECK:STDOUT: import Core//prelude/types/bool
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = 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 <invalid>
- // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
- // CHECK:STDOUT: %Core.import = import Core
- // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
- // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U 0
- // CHECK:STDOUT: } {
- // CHECK:STDOUT: %U.param: type = param U, runtime_param<invalid>
- // CHECK:STDOUT: %U.loc12: type = bind_symbolic_name U 0, %U.param [symbolic = %U.1 (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:
- // CHECK:STDOUT: class;
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: generic class @.1(%U.loc12: type) {
- // CHECK:STDOUT: %U.1: type = bind_symbolic_name U 0 [symbolic = %U.1 (constants.%U)]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !definition:
- // CHECK:STDOUT:
- // CHECK:STDOUT: class {
- // CHECK:STDOUT: %T.ref: <error> = name_ref T, <error> [template = <error>]
- // CHECK:STDOUT: %.loc16: <error> = field_decl x, element0 [template]
- // CHECK:STDOUT: %.loc17: <witness> = complete_type_witness <error> [template = <error>]
- // 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: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: specific @.1(constants.%U) {
- // CHECK:STDOUT: %U.1 => constants.%U
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|