| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- // 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 "foo";
- 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 "foo";
- class Class(T:! type) {
- var x: T;
- }
- fn F() -> CompleteClass(i32) {
- return {.n = 1};
- }
- // --- use_foo.carbon
- library "use_foo";
- import library "foo";
- fn Use() -> i32 {
- var v: CompleteClass(i32) = F();
- return v.F();
- }
- // --- fail_todo_use_foo.carbon
- library "fail_todo_use_foo";
- import library "foo";
- fn Use() -> i32 {
- var v: CompleteClass(i32) = F();
- // TODO: This should be accepted.
- // CHECK:STDERR: fail_todo_use_foo.carbon:[[@LINE+4]]:10: ERROR: Cannot implicitly convert from `CompleteClass` to `CompleteClass`.
- // CHECK:STDERR: return v.n;
- // CHECK:STDERR: ^~~
- // CHECK:STDERR:
- return v.n;
- }
- // --- fail_generic_arg_mismatch.carbon
- library "fail_generic_arg_mismatch";
- import library "foo";
- fn Use() {
- // TODO: Include the generic arguments in the formatted type name.
- // CHECK:STDERR: fail_generic_arg_mismatch.carbon:[[@LINE+4]]:3: ERROR: Cannot implicitly convert from `CompleteClass` to `CompleteClass`.
- // CHECK:STDERR: var v: CompleteClass(i32*) = F();
- // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // CHECK:STDERR:
- var v: CompleteClass(i32*) = F();
- }
- // --- fail_bad_foo.impl.carbon
- impl library "foo";
- // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+5]]:13: ERROR: Redeclaration differs at parameter 1.
- // CHECK:STDERR: class Class(U:! type) {
- // CHECK:STDERR: ^
- // CHECK:STDERR: fail_bad_foo.impl.carbon: Previous declaration's corresponding parameter here.
- // CHECK:STDERR:
- class Class(U:! type) {
- // CHECK:STDERR: fail_bad_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 [template]
- // 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 [template]
- // 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 [template]
- // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
- // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [template]
- // CHECK:STDOUT: %.3: type = struct_type {.n: i32} [template]
- // CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
- // CHECK:STDOUT: %CompleteClass.3: type = class_type @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: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .Class = %Class.decl
- // CHECK:STDOUT: .CompleteClass = %CompleteClass.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] {
- // CHECK:STDOUT: %T.loc4_13.1: type = param T
- // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %CompleteClass.decl: %CompleteClass.type = class_decl @CompleteClass [template = constants.%CompleteClass.1] {
- // CHECK:STDOUT: %T.loc6_21.1: type = param T
- // CHECK:STDOUT: %T.loc6_21.2: type = bind_symbolic_name T 0, %T.loc6_21.1 [symbolic = constants.%T]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %import_ref.2: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %import_ref.3: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
- // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, %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, (%.loc11_24.2) [template = constants.%CompleteClass.3]
- // CHECK:STDOUT: @F.2.%return: ref %CompleteClass.3 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @Class;
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @CompleteClass {
- // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
- // CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32.loc7, %.loc7_10.1 [template = i32]
- // CHECK:STDOUT: %.loc7_8: %.2 = field_decl n, element0 [template]
- // CHECK:STDOUT: %F.decl: %F.type.1 = fn_decl @F.1 [template = constants.%F.1] {
- // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
- // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32.loc8, %.loc8_13.1 [template = i32]
- // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // 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: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @F.1() -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.4]
- // CHECK:STDOUT: return %.loc8
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @F.2() -> %CompleteClass.3;
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- foo.impl.carbon
- // CHECK:STDOUT:
- // CHECK:STDOUT: constants {
- // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+28> [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 [template]
- // CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic]
- // CHECK:STDOUT: %.3: type = struct_type {.x: %T} [symbolic]
- // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template]
- // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template]
- // CHECK:STDOUT: %.4: type = struct_type {.n: i32} [template]
- // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass [template]
- // 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, (i32) [template]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %.5: type = ptr_type %.4 [template]
- // CHECK:STDOUT: %.6: i32 = int_literal 1 [template]
- // CHECK:STDOUT: %struct: %CompleteClass.3 = struct_value (%.6) [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .CompleteClass = %import_ref.2
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .Class = %Class.decl
- // CHECK:STDOUT: .F = %F.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1: %Class.type = import_ref ir0, inst+5, loaded [template = constants.%Class.1]
- // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir0, inst+12, loaded [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir0, inst+48, loaded [template = constants.%F]
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] {
- // CHECK:STDOUT: %T.loc4_13.1: type = param T
- // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.4 = import_ref ir0, inst+15, unloaded
- // CHECK:STDOUT: %import_ref.5 = import_ref ir0, inst+25, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref ir0, inst+33, unloaded
- // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir3, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
- // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, %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, (%.loc8_24.2) [template = constants.%CompleteClass.3]
- // CHECK:STDOUT: @F.%return: ref %CompleteClass.3 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @Class {
- // CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = constants.%T]
- // CHECK:STDOUT: %.loc5: %.2 = field_decl x, element0 [template]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%Class.2
- // CHECK:STDOUT: .x = %.loc5
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @CompleteClass {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = file.%import_ref.4
- // CHECK:STDOUT: .n = file.%import_ref.5
- // CHECK:STDOUT: .F = file.%import_ref.6
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @F() -> %return: %CompleteClass.3 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %.loc9_16: i32 = int_literal 1 [template = constants.%.6]
- // CHECK:STDOUT: %.loc9_17.1: %.4 = 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.%.6]
- // 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: --- 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: %Use.type: type = fn_type @Use [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: %CompleteClass.2: type = class_type @CompleteClass [template]
- // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+26> [symbolic]
- // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (i32) [template]
- // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
- // CHECK:STDOUT: %F.type.1: type = fn_type @F.1 [template]
- // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [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: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Class = %import_ref.1
- // CHECK:STDOUT: .CompleteClass = %import_ref.2
- // CHECK:STDOUT: .F = %import_ref.3
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .Use = %Use.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+5, unloaded
- // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir1, inst+12, loaded [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %import_ref.3: %F.type.1 = import_ref ir1, inst+48, loaded [template = constants.%F.1]
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
- // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc5_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
- // CHECK:STDOUT: %.loc5_13.2: type = converted %int.make_type_32, %.loc5_13.1 [template = i32]
- // CHECK:STDOUT: @Use.%return: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+15, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+25, unloaded
- // CHECK:STDOUT: %import_ref.7: %F.type.2 = import_ref ir1, inst+33, loaded [template = constants.%F.2]
- // CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @CompleteClass {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = file.%import_ref.5
- // CHECK:STDOUT: .n = file.%import_ref.6
- // CHECK:STDOUT: .F = file.%import_ref.7
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Use() -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, file.%import_ref.2 [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc6_23.1: type = value_of_initializer %int.make_type_32 [template = i32]
- // CHECK:STDOUT: %.loc6_23.2: type = converted %int.make_type_32, %.loc6_23.1 [template = i32]
- // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, (%.loc6_23.2) [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.1 = name_ref F, file.%import_ref.3 [template = constants.%F.1]
- // 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: %F.ref.loc7: %F.type.2 = name_ref F, file.%import_ref.7 [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: fn @F.1() -> %CompleteClass.3;
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @F.2() -> i32;
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_todo_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: %Use.type: type = fn_type @Use [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: %CompleteClass.2: type = class_type @CompleteClass [template]
- // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+26> [symbolic]
- // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (i32) [template]
- // CHECK:STDOUT: %.3: type = ptr_type %.2 [template]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: %.4: type = unbound_element_type %CompleteClass.2, i32 [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Class = %import_ref.1
- // CHECK:STDOUT: .CompleteClass = %import_ref.2
- // CHECK:STDOUT: .F = %import_ref.3
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .Use = %Use.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+5, unloaded
- // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir1, inst+12, loaded [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir1, inst+48, loaded [template = constants.%F]
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {
- // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc5_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
- // CHECK:STDOUT: %.loc5_13.2: type = converted %int.make_type_32, %.loc5_13.1 [template = i32]
- // CHECK:STDOUT: @Use.%return: ref i32 = var <return slot>
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+15, unloaded
- // CHECK:STDOUT: %import_ref.6: %.4 = import_ref ir1, inst+25, loaded [template = imports.%.1]
- // CHECK:STDOUT: %import_ref.7 = import_ref ir1, inst+33, unloaded
- // CHECK:STDOUT: %import_ref.8: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @CompleteClass {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = file.%import_ref.5
- // CHECK:STDOUT: .n = file.%import_ref.6
- // CHECK:STDOUT: .F = file.%import_ref.7
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Use() -> i32 {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, file.%import_ref.2 [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc6_23.1: type = value_of_initializer %int.make_type_32 [template = i32]
- // CHECK:STDOUT: %.loc6_23.2: type = converted %int.make_type_32, %.loc6_23.1 [template = i32]
- // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, (%.loc6_23.2) [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 = name_ref F, file.%import_ref.3 [template = constants.%F]
- // CHECK:STDOUT: %.loc6_7: ref %CompleteClass.3 = splice_block %v.var {}
- // CHECK:STDOUT: %F.call: init %CompleteClass.3 = call %F.ref() to %.loc6_7
- // CHECK:STDOUT: assign %v.var, %F.call
- // CHECK:STDOUT: %v.ref: ref %CompleteClass.3 = name_ref v, %v
- // CHECK:STDOUT: %n.ref: %.4 = name_ref n, file.%import_ref.6 [template = imports.%.1]
- // CHECK:STDOUT: %.loc12: i32 = class_element_access <error>, element0 [template = <error>]
- // CHECK:STDOUT: return <error>
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @F() -> %CompleteClass.3;
- // 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: %CompleteClass.2: type = class_type @CompleteClass [template]
- // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+17> [symbolic]
- // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
- // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
- // CHECK:STDOUT: %.3: type = ptr_type i32 [template]
- // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, (%.3) [template]
- // CHECK:STDOUT: %.4: type = ptr_type %.2 [template]
- // CHECK:STDOUT: %CompleteClass.4: type = class_type @CompleteClass, (i32) [template]
- // CHECK:STDOUT: %F.type: type = fn_type @F [template]
- // CHECK:STDOUT: %F: %F.type = struct_value () [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Class = %import_ref.1
- // CHECK:STDOUT: .CompleteClass = %import_ref.2
- // CHECK:STDOUT: .F = %import_ref.3
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: .Use = %Use.decl
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1 = import_ref ir1, inst+5, unloaded
- // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref ir1, inst+12, loaded [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %import_ref.3: %F.type = import_ref ir1, inst+48, loaded [template = constants.%F]
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {}
- // CHECK:STDOUT: %import_ref.4 = import_ref ir1, inst+15, unloaded
- // CHECK:STDOUT: %import_ref.5 = import_ref ir1, inst+25, unloaded
- // CHECK:STDOUT: %import_ref.6 = import_ref ir1, inst+33, unloaded
- // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref ir4, inst+3, loaded [template = constants.%Int32]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @CompleteClass {
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = file.%import_ref.4
- // CHECK:STDOUT: .n = file.%import_ref.5
- // CHECK:STDOUT: .F = file.%import_ref.6
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Use() {
- // CHECK:STDOUT: !entry:
- // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, file.%import_ref.2 [template = constants.%CompleteClass.1]
- // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
- // CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %int.make_type_32 [template = i32]
- // CHECK:STDOUT: %.loc11_27.2: type = converted %int.make_type_32, %.loc11_27.1 [template = i32]
- // CHECK:STDOUT: %.loc11_27.3: type = ptr_type i32 [template = constants.%.3]
- // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, (%.loc11_27.3) [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 = name_ref F, file.%import_ref.3 [template = constants.%F]
- // CHECK:STDOUT: %.loc11_33: ref %CompleteClass.4 = temporary_storage
- // CHECK:STDOUT: %F.call: init %CompleteClass.4 = call %F.ref() to %.loc11_33
- // CHECK:STDOUT: assign %v.var, <error>
- // CHECK:STDOUT: return
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
- // CHECK:STDOUT:
- // CHECK:STDOUT: fn @F() -> %CompleteClass.4;
- // CHECK:STDOUT:
- // CHECK:STDOUT: --- fail_bad_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: %Class.2: type = class_type @Class [template]
- // CHECK:STDOUT: %T: type = bind_symbolic_name T 0, <unexpected instref inst+14> [symbolic]
- // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template]
- // CHECK:STDOUT: %.2: %.type = struct_value () [template]
- // CHECK:STDOUT: %.3: type = class_type @.1 [template]
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: file {
- // CHECK:STDOUT: package: <namespace> = namespace [template] {
- // CHECK:STDOUT: .Class = %import_ref.1
- // CHECK:STDOUT: .CompleteClass = %import_ref.2
- // CHECK:STDOUT: .F = %import_ref.3
- // CHECK:STDOUT: .Core = %Core
- // CHECK:STDOUT: }
- // CHECK:STDOUT: %import_ref.1: %Class.type = import_ref ir0, inst+5, loaded [template = constants.%Class.1]
- // CHECK:STDOUT: %import_ref.2 = import_ref ir0, inst+12, unloaded
- // CHECK:STDOUT: %import_ref.3 = import_ref ir0, inst+48, unloaded
- // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
- // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
- // CHECK:STDOUT: %U.loc9_13.1: type = param U
- // CHECK:STDOUT: %U.loc9_13.2: type = bind_symbolic_name U 0, %U.loc9_13.1 [symbolic = constants.%U]
- // CHECK:STDOUT: }
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @Class;
- // CHECK:STDOUT:
- // CHECK:STDOUT: class @.1 {
- // CHECK:STDOUT: %T.ref: <error> = name_ref T, <error> [template = <error>]
- // CHECK:STDOUT: %.loc13: <error> = field_decl x, element0 [template]
- // CHECK:STDOUT:
- // CHECK:STDOUT: !members:
- // CHECK:STDOUT: .Self = constants.%.3
- // CHECK:STDOUT: .x = %.loc13
- // CHECK:STDOUT: }
- // CHECK:STDOUT:
|