import.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/int.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/struct/import.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/struct/import.carbon
  12. // --- implicit.carbon
  13. package Implicit;
  14. var a_ref: {.a: i32} = {.a = 0};
  15. var b_ref: {.a: {.b: i32, .c: (i32,)}, .d: i32} =
  16. {.a = {.b = 0, .c = (0,)}, .d = 0};
  17. class C(S:! {.a: i32, .b: i32}) {}
  18. fn F() -> C({.a = 1, .b = 2});
  19. // --- implicit.impl.carbon
  20. impl package Implicit;
  21. //@dump-sem-ir-begin
  22. var a: {.a: i32} = a_ref;
  23. var b: {.a: {.b: i32, .c: (i32,)}, .d: i32} = b_ref;
  24. var c: C({.a = 1, .b = 2}) = F();
  25. //@dump-sem-ir-end
  26. // --- fail_bad_type.impl.carbon
  27. impl package Implicit;
  28. // CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE+8]]:14: error: missing value for field `a` in struct initialization [StructInitMissingFieldInLiteral]
  29. // CHECK:STDERR: var c_bad: C({.c = 1, .d = 2}) = F();
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~~~
  31. // CHECK:STDERR: fail_bad_type.impl.carbon:[[@LINE-4]]:1: in import [InImport]
  32. // CHECK:STDERR: implicit.carbon:8:9: note: initializing generic parameter `S` declared here [InitializingGenericParam]
  33. // CHECK:STDERR: class C(S:! {.a: i32, .b: i32}) {}
  34. // CHECK:STDERR: ^
  35. // CHECK:STDERR:
  36. var c_bad: C({.c = 1, .d = 2}) = F();
  37. // --- fail_bad_value.impl.carbon
  38. impl package Implicit;
  39. // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+7]]:1: error: cannot implicitly convert expression of type `C({.a = 1, .b = 2})` to `C({.a = 3, .b = 4})` [ConversionFailure]
  40. // CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F();
  41. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  42. // CHECK:STDERR: fail_bad_value.impl.carbon:[[@LINE+4]]:1: note: type `C({.a = 1, .b = 2})` does not implement interface `Core.ImplicitAs(C({.a = 3, .b = 4}))` [MissingImplInMemberAccessNote]
  43. // CHECK:STDERR: var c_bad: C({.a = 3, .b = 4}) = F();
  44. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. // CHECK:STDERR:
  46. var c_bad: C({.a = 3, .b = 4}) = F();
  47. // --- symbolic_decl.carbon
  48. library "[[@TEST_NAME]]";
  49. interface I {
  50. let val:! {.x: i32};
  51. }
  52. class C {}
  53. impl C as I where .val = {.x = 1} {}
  54. // --- import_symbolic_decl.carbon
  55. library "[[@TEST_NAME]]";
  56. import library "symbolic_decl";
  57. fn F() -> {.x: i32} {
  58. //@dump-sem-ir-begin
  59. return (C as I).val;
  60. //@dump-sem-ir-end
  61. }
  62. // CHECK:STDOUT: --- implicit.impl.carbon
  63. // CHECK:STDOUT:
  64. // CHECK:STDOUT: constants {
  65. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  66. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  67. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.60d: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  68. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.846: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.60d = struct_value () [symbolic]
  69. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  70. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  71. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [concrete]
  72. // CHECK:STDOUT: %pattern_type.b54: type = pattern_type %struct_type.a [concrete]
  73. // CHECK:STDOUT: %.6a4: ref %i32 = struct_access imports.%a_ref.var, element0 [concrete]
  74. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  75. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  76. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.809: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  77. // CHECK:STDOUT: %Int.as.Copy.impl.Op.8e1: %Int.as.Copy.impl.Op.type.809 = struct_value () [symbolic]
  78. // CHECK:STDOUT: %Copy.impl_witness.54b: <witness> = impl_witness imports.%Copy.impl_witness_table.a25, @Int.as.Copy.impl(%int_32) [concrete]
  79. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.71a: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  80. // CHECK:STDOUT: %Int.as.Copy.impl.Op.a17: %Int.as.Copy.impl.Op.type.71a = struct_value () [concrete]
  81. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.54b) [concrete]
  82. // CHECK:STDOUT: %.5b9: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet [concrete]
  83. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.a17, @Int.as.Copy.impl.Op(%int_32) [concrete]
  84. // CHECK:STDOUT: %tuple.type.85c: type = tuple_type (type) [concrete]
  85. // CHECK:STDOUT: %tuple.38e: %tuple.type.85c = tuple_value (%i32) [concrete]
  86. // CHECK:STDOUT: %tuple.type.dd4: type = tuple_type (%i32) [concrete]
  87. // CHECK:STDOUT: %struct_type.b.c: type = struct_type {.b: %i32, .c: %tuple.type.dd4} [concrete]
  88. // CHECK:STDOUT: %struct_type.a.d.9db: type = struct_type {.a: %struct_type.b.c, .d: %i32} [concrete]
  89. // CHECK:STDOUT: %pattern_type.020: type = pattern_type %struct_type.a.d.9db [concrete]
  90. // CHECK:STDOUT: %.599: ref %struct_type.b.c = struct_access imports.%b_ref.var, element0 [concrete]
  91. // CHECK:STDOUT: %.eaa: ref %struct_type.b.c = struct_access file.%b.var, element0 [concrete]
  92. // CHECK:STDOUT: %.34e: ref %i32 = struct_access %.599, element0 [concrete]
  93. // CHECK:STDOUT: %.42f: ref %i32 = struct_access %.eaa, element0 [concrete]
  94. // CHECK:STDOUT: %.9e2: ref %tuple.type.dd4 = struct_access %.599, element1 [concrete]
  95. // CHECK:STDOUT: %.f05: ref %tuple.type.dd4 = struct_access %.eaa, element1 [concrete]
  96. // CHECK:STDOUT: %tuple.elem0.cbb: ref %i32 = tuple_access %.9e2, element0 [concrete]
  97. // CHECK:STDOUT: %.0e8: ref %i32 = struct_access imports.%b_ref.var, element1 [concrete]
  98. // CHECK:STDOUT: %.7e1: ref %i32 = struct_access file.%b.var, element1 [concrete]
  99. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  100. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  101. // CHECK:STDOUT: %struct_type.a.b.5ca: type = struct_type {.a: %i32, .b: %i32} [concrete]
  102. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  103. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  104. // CHECK:STDOUT: %struct_type.a.b.cfd: type = struct_type {.a: Core.IntLiteral, .b: Core.IntLiteral} [concrete]
  105. // CHECK:STDOUT: %struct.4aa: %struct_type.a.b.cfd = struct_value (%int_1.5b8, %int_2.ecc) [concrete]
  106. // CHECK:STDOUT: %ImplicitAs.type.774: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  107. // CHECK:STDOUT: %ImplicitAs.Convert.type.ea0: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  108. // CHECK:STDOUT: %ImplicitAs.impl_witness.a38: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.99d, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  109. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.8d4: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  110. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.a89: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.8d4 = struct_value () [concrete]
  111. // CHECK:STDOUT: %ImplicitAs.facet: %ImplicitAs.type.774 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.a38) [concrete]
  112. // CHECK:STDOUT: %.dc8: type = fn_type_with_self_type %ImplicitAs.Convert.type.ea0, %ImplicitAs.facet [concrete]
  113. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.5b6: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.a89 [concrete]
  114. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.a89, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  115. // CHECK:STDOUT: %bound_method.3c6: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  116. // CHECK:STDOUT: %int_1.47b: %i32 = int_value 1 [concrete]
  117. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.f8f: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.a89 [concrete]
  118. // CHECK:STDOUT: %bound_method.502: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  119. // CHECK:STDOUT: %int_2.d0d: %i32 = int_value 2 [concrete]
  120. // CHECK:STDOUT: %struct.cd9: %struct_type.a.b.5ca = struct_value (%int_1.47b, %int_2.d0d) [concrete]
  121. // CHECK:STDOUT: %C.a8a: type = class_type @C, @C(%struct.cd9) [concrete]
  122. // CHECK:STDOUT: %pattern_type.a5a: type = pattern_type %C.a8a [concrete]
  123. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  124. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: imports {
  128. // CHECK:STDOUT: %Implicit.a_ref: ref %struct_type.a = import_ref Implicit//default, a_ref, loaded [concrete = %a_ref.var]
  129. // CHECK:STDOUT: %Implicit.b_ref: ref %struct_type.a.d.9db = import_ref Implicit//default, b_ref, loaded [concrete = %b_ref.var]
  130. // CHECK:STDOUT: %Implicit.C: %C.type = import_ref Implicit//default, C, loaded [concrete = constants.%C.generic]
  131. // CHECK:STDOUT: %Implicit.F: %F.type = import_ref Implicit//default, F, loaded [concrete = constants.%F]
  132. // CHECK:STDOUT: %Implicit.import_ref.39e: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.60d) = import_ref Implicit//default, inst{{[0-9A-F]+}} [indirect], loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.846)]
  133. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.99d = impl_witness_table (%Implicit.import_ref.39e), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  134. // CHECK:STDOUT: %a_ref.patt: %pattern_type.b54 = ref_binding_pattern a_ref [concrete]
  135. // CHECK:STDOUT: %a_ref.var_patt: %pattern_type.b54 = var_pattern %a_ref.patt [concrete]
  136. // CHECK:STDOUT: %a_ref.var: ref %struct_type.a = var %a_ref.var_patt [concrete]
  137. // CHECK:STDOUT: %Core.import_ref.c6f: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.809) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.8e1)]
  138. // CHECK:STDOUT: %Copy.impl_witness_table.a25 = impl_witness_table (%Core.import_ref.c6f), @Int.as.Copy.impl [concrete]
  139. // CHECK:STDOUT: %b_ref.patt: %pattern_type.020 = ref_binding_pattern b_ref [concrete]
  140. // CHECK:STDOUT: %b_ref.var_patt: %pattern_type.020 = var_pattern %b_ref.patt [concrete]
  141. // CHECK:STDOUT: %b_ref.var: ref %struct_type.a.d.9db = var %b_ref.var_patt [concrete]
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: file {
  145. // CHECK:STDOUT: name_binding_decl {
  146. // CHECK:STDOUT: %a.patt: %pattern_type.b54 = ref_binding_pattern a [concrete]
  147. // CHECK:STDOUT: %a.var_patt: %pattern_type.b54 = var_pattern %a.patt [concrete]
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT: %a.var: ref %struct_type.a = var %a.var_patt [concrete]
  150. // CHECK:STDOUT: %.loc5: type = splice_block %struct_type.a [concrete = constants.%struct_type.a] {
  151. // CHECK:STDOUT: %int_32.loc5: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  152. // CHECK:STDOUT: %i32.loc5: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  153. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %i32} [concrete = constants.%struct_type.a]
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: %a: ref %struct_type.a = ref_binding a, %a.var [concrete = %a.var]
  156. // CHECK:STDOUT: name_binding_decl {
  157. // CHECK:STDOUT: %b.patt: %pattern_type.020 = ref_binding_pattern b [concrete]
  158. // CHECK:STDOUT: %b.var_patt: %pattern_type.020 = var_pattern %b.patt [concrete]
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT: %b.var: ref %struct_type.a.d.9db = var %b.var_patt [concrete]
  161. // CHECK:STDOUT: %.loc6_43: type = splice_block %struct_type.a.d [concrete = constants.%struct_type.a.d.9db] {
  162. // CHECK:STDOUT: %int_32.loc6_18: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  163. // CHECK:STDOUT: %i32.loc6_18: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  164. // CHECK:STDOUT: %int_32.loc6_28: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  165. // CHECK:STDOUT: %i32.loc6_28: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  166. // CHECK:STDOUT: %.loc6_32.1: %tuple.type.85c = tuple_literal (%i32.loc6_28) [concrete = constants.%tuple.38e]
  167. // CHECK:STDOUT: %.loc6_32.2: type = converted %.loc6_32.1, constants.%tuple.type.dd4 [concrete = constants.%tuple.type.dd4]
  168. // CHECK:STDOUT: %struct_type.b.c: type = struct_type {.b: %i32, .c: %tuple.type.dd4} [concrete = constants.%struct_type.b.c]
  169. // CHECK:STDOUT: %int_32.loc6_40: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  170. // CHECK:STDOUT: %i32.loc6_40: type = class_type @Int, @Int(constants.%int_32) [concrete = constants.%i32]
  171. // CHECK:STDOUT: %struct_type.a.d: type = struct_type {.a: %struct_type.b.c, .d: %i32} [concrete = constants.%struct_type.a.d.9db]
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT: %b: ref %struct_type.a.d.9db = ref_binding b, %b.var [concrete = %b.var]
  174. // CHECK:STDOUT: name_binding_decl {
  175. // CHECK:STDOUT: %c.patt: %pattern_type.a5a = ref_binding_pattern c [concrete]
  176. // CHECK:STDOUT: %c.var_patt: %pattern_type.a5a = var_pattern %c.patt [concrete]
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT: %c.var: ref %C.a8a = var %c.var_patt [concrete]
  179. // CHECK:STDOUT: %.loc7_26.1: type = splice_block %C [concrete = constants.%C.a8a] {
  180. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, imports.%Implicit.C [concrete = constants.%C.generic]
  181. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  182. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  183. // CHECK:STDOUT: %.loc7_25.1: %struct_type.a.b.cfd = struct_literal (%int_1, %int_2) [concrete = constants.%struct.4aa]
  184. // CHECK:STDOUT: %impl.elem0.loc7_25.1: %.dc8 = impl_witness_access constants.%ImplicitAs.impl_witness.a38, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.a89]
  185. // CHECK:STDOUT: %bound_method.loc7_25.1: <bound method> = bound_method %int_1, %impl.elem0.loc7_25.1 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.5b6]
  186. // CHECK:STDOUT: %specific_fn.loc7_25.1: <specific function> = specific_function %impl.elem0.loc7_25.1, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  187. // CHECK:STDOUT: %bound_method.loc7_25.2: <bound method> = bound_method %int_1, %specific_fn.loc7_25.1 [concrete = constants.%bound_method.3c6]
  188. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc7_25.1: init %i32 = call %bound_method.loc7_25.2(%int_1) [concrete = constants.%int_1.47b]
  189. // CHECK:STDOUT: %.loc7_25.2: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc7_25.1 [concrete = constants.%int_1.47b]
  190. // CHECK:STDOUT: %.loc7_25.3: %i32 = converted %int_1, %.loc7_25.2 [concrete = constants.%int_1.47b]
  191. // CHECK:STDOUT: %impl.elem0.loc7_25.2: %.dc8 = impl_witness_access constants.%ImplicitAs.impl_witness.a38, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.a89]
  192. // CHECK:STDOUT: %bound_method.loc7_25.3: <bound method> = bound_method %int_2, %impl.elem0.loc7_25.2 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound.f8f]
  193. // CHECK:STDOUT: %specific_fn.loc7_25.2: <specific function> = specific_function %impl.elem0.loc7_25.2, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  194. // CHECK:STDOUT: %bound_method.loc7_25.4: <bound method> = bound_method %int_2, %specific_fn.loc7_25.2 [concrete = constants.%bound_method.502]
  195. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc7_25.2: init %i32 = call %bound_method.loc7_25.4(%int_2) [concrete = constants.%int_2.d0d]
  196. // CHECK:STDOUT: %.loc7_25.4: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call.loc7_25.2 [concrete = constants.%int_2.d0d]
  197. // CHECK:STDOUT: %.loc7_25.5: %i32 = converted %int_2, %.loc7_25.4 [concrete = constants.%int_2.d0d]
  198. // CHECK:STDOUT: %struct: %struct_type.a.b.5ca = struct_value (%.loc7_25.3, %.loc7_25.5) [concrete = constants.%struct.cd9]
  199. // CHECK:STDOUT: %.loc7_26.2: %struct_type.a.b.5ca = converted %.loc7_25.1, %struct [concrete = constants.%struct.cd9]
  200. // CHECK:STDOUT: %C: type = class_type @C, @C(constants.%struct.cd9) [concrete = constants.%C.a8a]
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %c: ref %C.a8a = ref_binding c, %c.var [concrete = %c.var]
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: fn @__global_init() {
  206. // CHECK:STDOUT: !entry:
  207. // CHECK:STDOUT: %a_ref.ref: ref %struct_type.a = name_ref a_ref, imports.%Implicit.a_ref [concrete = imports.%a_ref.var]
  208. // CHECK:STDOUT: %.loc5_20.1: ref %i32 = struct_access %a_ref.ref, element0 [concrete = constants.%.6a4]
  209. // CHECK:STDOUT: %.loc5_20.2: %i32 = acquire_value %.loc5_20.1
  210. // CHECK:STDOUT: %impl.elem0.loc5: %.5b9 = impl_witness_access constants.%Copy.impl_witness.54b, element0 [concrete = constants.%Int.as.Copy.impl.Op.a17]
  211. // CHECK:STDOUT: %bound_method.loc5_20.1: <bound method> = bound_method %.loc5_20.2, %impl.elem0.loc5
  212. // CHECK:STDOUT: %specific_fn.loc5: <specific function> = specific_function %impl.elem0.loc5, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  213. // CHECK:STDOUT: %bound_method.loc5_20.2: <bound method> = bound_method %.loc5_20.2, %specific_fn.loc5
  214. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc5: init %i32 = call %bound_method.loc5_20.2(%.loc5_20.2)
  215. // CHECK:STDOUT: %.loc5_20.3: init %struct_type.a = struct_init (%Int.as.Copy.impl.Op.call.loc5) to file.%a.var
  216. // CHECK:STDOUT: %.loc5_1: init %struct_type.a = converted %a_ref.ref, %.loc5_20.3
  217. // CHECK:STDOUT: assign file.%a.var, %.loc5_1
  218. // CHECK:STDOUT: %b_ref.ref: ref %struct_type.a.d.9db = name_ref b_ref, imports.%Implicit.b_ref [concrete = imports.%b_ref.var]
  219. // CHECK:STDOUT: %.loc6_47.1: ref %struct_type.b.c = struct_access %b_ref.ref, element0 [concrete = constants.%.599]
  220. // CHECK:STDOUT: %.loc6_47.2: ref %i32 = struct_access %.loc6_47.1, element0 [concrete = constants.%.34e]
  221. // CHECK:STDOUT: %.loc6_47.3: %i32 = acquire_value %.loc6_47.2
  222. // CHECK:STDOUT: %impl.elem0.loc6_47.1: %.5b9 = impl_witness_access constants.%Copy.impl_witness.54b, element0 [concrete = constants.%Int.as.Copy.impl.Op.a17]
  223. // CHECK:STDOUT: %bound_method.loc6_47.1: <bound method> = bound_method %.loc6_47.3, %impl.elem0.loc6_47.1
  224. // CHECK:STDOUT: %specific_fn.loc6_47.1: <specific function> = specific_function %impl.elem0.loc6_47.1, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  225. // CHECK:STDOUT: %bound_method.loc6_47.2: <bound method> = bound_method %.loc6_47.3, %specific_fn.loc6_47.1
  226. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc6_47.1: init %i32 = call %bound_method.loc6_47.2(%.loc6_47.3)
  227. // CHECK:STDOUT: %.loc6_47.4: ref %struct_type.b.c = struct_access file.%b.var, element0 [concrete = constants.%.eaa]
  228. // CHECK:STDOUT: %.loc6_47.5: ref %i32 = struct_access %.loc6_47.4, element0 [concrete = constants.%.42f]
  229. // CHECK:STDOUT: %.loc6_47.6: init %i32 = initialize_from %Int.as.Copy.impl.Op.call.loc6_47.1 to %.loc6_47.5
  230. // CHECK:STDOUT: %.loc6_47.7: ref %tuple.type.dd4 = struct_access %.loc6_47.1, element1 [concrete = constants.%.9e2]
  231. // CHECK:STDOUT: %tuple.elem0: ref %i32 = tuple_access %.loc6_47.7, element0 [concrete = constants.%tuple.elem0.cbb]
  232. // CHECK:STDOUT: %.loc6_47.8: %i32 = acquire_value %tuple.elem0
  233. // CHECK:STDOUT: %impl.elem0.loc6_47.2: %.5b9 = impl_witness_access constants.%Copy.impl_witness.54b, element0 [concrete = constants.%Int.as.Copy.impl.Op.a17]
  234. // CHECK:STDOUT: %bound_method.loc6_47.3: <bound method> = bound_method %.loc6_47.8, %impl.elem0.loc6_47.2
  235. // CHECK:STDOUT: %specific_fn.loc6_47.2: <specific function> = specific_function %impl.elem0.loc6_47.2, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  236. // CHECK:STDOUT: %bound_method.loc6_47.4: <bound method> = bound_method %.loc6_47.8, %specific_fn.loc6_47.2
  237. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc6_47.2: init %i32 = call %bound_method.loc6_47.4(%.loc6_47.8)
  238. // CHECK:STDOUT: %.loc6_47.9: ref %tuple.type.dd4 = struct_access %.loc6_47.4, element1 [concrete = constants.%.f05]
  239. // CHECK:STDOUT: %.loc6_47.10: init %tuple.type.dd4 = tuple_init (%Int.as.Copy.impl.Op.call.loc6_47.2) to %.loc6_47.9
  240. // CHECK:STDOUT: %.loc6_47.11: init %tuple.type.dd4 = converted %.loc6_47.7, %.loc6_47.10
  241. // CHECK:STDOUT: %.loc6_47.12: init %tuple.type.dd4 = initialize_from %.loc6_47.11 to %.loc6_47.9
  242. // CHECK:STDOUT: %.loc6_47.13: init %struct_type.b.c = struct_init (%.loc6_47.6, %.loc6_47.12) to %.loc6_47.4
  243. // CHECK:STDOUT: %.loc6_47.14: init %struct_type.b.c = converted %.loc6_47.1, %.loc6_47.13
  244. // CHECK:STDOUT: %.loc6_47.15: ref %i32 = struct_access %b_ref.ref, element1 [concrete = constants.%.0e8]
  245. // CHECK:STDOUT: %.loc6_47.16: %i32 = acquire_value %.loc6_47.15
  246. // CHECK:STDOUT: %impl.elem0.loc6_47.3: %.5b9 = impl_witness_access constants.%Copy.impl_witness.54b, element0 [concrete = constants.%Int.as.Copy.impl.Op.a17]
  247. // CHECK:STDOUT: %bound_method.loc6_47.5: <bound method> = bound_method %.loc6_47.16, %impl.elem0.loc6_47.3
  248. // CHECK:STDOUT: %specific_fn.loc6_47.3: <specific function> = specific_function %impl.elem0.loc6_47.3, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  249. // CHECK:STDOUT: %bound_method.loc6_47.6: <bound method> = bound_method %.loc6_47.16, %specific_fn.loc6_47.3
  250. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call.loc6_47.3: init %i32 = call %bound_method.loc6_47.6(%.loc6_47.16)
  251. // CHECK:STDOUT: %.loc6_47.17: ref %i32 = struct_access file.%b.var, element1 [concrete = constants.%.7e1]
  252. // CHECK:STDOUT: %.loc6_47.18: init %i32 = initialize_from %Int.as.Copy.impl.Op.call.loc6_47.3 to %.loc6_47.17
  253. // CHECK:STDOUT: %.loc6_47.19: init %struct_type.a.d.9db = struct_init (%.loc6_47.14, %.loc6_47.18) to file.%b.var
  254. // CHECK:STDOUT: %.loc6_1: init %struct_type.a.d.9db = converted %b_ref.ref, %.loc6_47.19
  255. // CHECK:STDOUT: assign file.%b.var, %.loc6_1
  256. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, imports.%Implicit.F [concrete = constants.%F]
  257. // CHECK:STDOUT: %.loc7: ref %C.a8a = splice_block file.%c.var [concrete = file.%c.var] {}
  258. // CHECK:STDOUT: %F.call: init %C.a8a = call %F.ref() to %.loc7
  259. // CHECK:STDOUT: assign file.%c.var, %F.call
  260. // CHECK:STDOUT: <elided>
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: --- import_symbolic_decl.carbon
  264. // CHECK:STDOUT:
  265. // CHECK:STDOUT: constants {
  266. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  267. // CHECK:STDOUT: %N: Core.IntLiteral = symbolic_binding N, 0 [symbolic]
  268. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  269. // CHECK:STDOUT: %struct_type.x: type = struct_type {.x: %i32} [concrete]
  270. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  271. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  272. // CHECK:STDOUT: %int_1: %i32 = int_value 1 [concrete]
  273. // CHECK:STDOUT: %struct: %struct_type.x = struct_value (%int_1) [concrete]
  274. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness imports.%I.impl_witness_table [concrete]
  275. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C, (%I.impl_witness) [concrete]
  276. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  277. // CHECK:STDOUT: %assoc0.862: %I.assoc_type = assoc_entity element0, imports.%Main.import_ref.380 [concrete]
  278. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  279. // CHECK:STDOUT: %Copy.Op.type: type = fn_type @Copy.Op [concrete]
  280. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.24b: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%N) [symbolic]
  281. // CHECK:STDOUT: %Int.as.Copy.impl.Op.c95: %Int.as.Copy.impl.Op.type.24b = struct_value () [symbolic]
  282. // CHECK:STDOUT: %Copy.impl_witness.fb7: <witness> = impl_witness imports.%Copy.impl_witness_table.b6a, @Int.as.Copy.impl(%int_32) [concrete]
  283. // CHECK:STDOUT: %Int.as.Copy.impl.Op.type.469: type = fn_type @Int.as.Copy.impl.Op, @Int.as.Copy.impl(%int_32) [concrete]
  284. // CHECK:STDOUT: %Int.as.Copy.impl.Op.dfd: %Int.as.Copy.impl.Op.type.469 = struct_value () [concrete]
  285. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %i32, (%Copy.impl_witness.fb7) [concrete]
  286. // CHECK:STDOUT: %.65f: type = fn_type_with_self_type %Copy.Op.type, %Copy.facet [concrete]
  287. // CHECK:STDOUT: %Int.as.Copy.impl.Op.bound: <bound method> = bound_method %int_1, %Int.as.Copy.impl.Op.dfd [concrete]
  288. // CHECK:STDOUT: %Int.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %Int.as.Copy.impl.Op.dfd, @Int.as.Copy.impl.Op(%int_32) [concrete]
  289. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %int_1, %Int.as.Copy.impl.Op.specific_fn [concrete]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: imports {
  293. // CHECK:STDOUT: %Main.I: type = import_ref Main//symbolic_decl, I, loaded [concrete = constants.%I.type]
  294. // CHECK:STDOUT: %Main.C: type = import_ref Main//symbolic_decl, C, loaded [concrete = constants.%C]
  295. // CHECK:STDOUT: %Main.import_ref.1fc: %I.assoc_type = import_ref Main//symbolic_decl, loc5_10, loaded [concrete = constants.%assoc0.862]
  296. // CHECK:STDOUT: %Main.import_ref.1ec: %struct_type.x = import_ref Main//symbolic_decl, loc10_35, loaded [concrete = constants.%struct]
  297. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%Main.import_ref.1ec), @C.as.I.impl [concrete]
  298. // CHECK:STDOUT: %Main.import_ref.380: %struct_type.x = import_ref Main//symbolic_decl, loc5_10, loaded [concrete = %val]
  299. // CHECK:STDOUT: %val: %struct_type.x = assoc_const_decl @val [concrete] {}
  300. // CHECK:STDOUT: %Core.import_ref.d12: @Int.as.Copy.impl.%Int.as.Copy.impl.Op.type (%Int.as.Copy.impl.Op.type.24b) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.Copy.impl.%Int.as.Copy.impl.Op (constants.%Int.as.Copy.impl.Op.c95)]
  301. // CHECK:STDOUT: %Copy.impl_witness_table.b6a = impl_witness_table (%Core.import_ref.d12), @Int.as.Copy.impl [concrete]
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: fn @F() -> %struct_type.x {
  305. // CHECK:STDOUT: !entry:
  306. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%Main.C [concrete = constants.%C]
  307. // CHECK:STDOUT: %I.ref: type = name_ref I, imports.%Main.I [concrete = constants.%I.type]
  308. // CHECK:STDOUT: %I.facet: %I.type = facet_value %C.ref, (constants.%I.impl_witness) [concrete = constants.%I.facet]
  309. // CHECK:STDOUT: %.loc7_13: %I.type = converted %C.ref, %I.facet [concrete = constants.%I.facet]
  310. // CHECK:STDOUT: %val.ref: %I.assoc_type = name_ref val, imports.%Main.import_ref.1fc [concrete = constants.%assoc0.862]
  311. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc7_13 [concrete = constants.%C]
  312. // CHECK:STDOUT: %.loc7_18.1: type = converted %.loc7_13, %as_type [concrete = constants.%C]
  313. // CHECK:STDOUT: %impl.elem0.loc7_18.1: %struct_type.x = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%struct]
  314. // CHECK:STDOUT: %.loc7_18.2: %i32 = struct_access %impl.elem0.loc7_18.1, element0 [concrete = constants.%int_1]
  315. // CHECK:STDOUT: %impl.elem0.loc7_18.2: %.65f = impl_witness_access constants.%Copy.impl_witness.fb7, element0 [concrete = constants.%Int.as.Copy.impl.Op.dfd]
  316. // CHECK:STDOUT: %bound_method.loc7_18.1: <bound method> = bound_method %.loc7_18.2, %impl.elem0.loc7_18.2 [concrete = constants.%Int.as.Copy.impl.Op.bound]
  317. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0.loc7_18.2, @Int.as.Copy.impl.Op(constants.%int_32) [concrete = constants.%Int.as.Copy.impl.Op.specific_fn]
  318. // CHECK:STDOUT: %bound_method.loc7_18.2: <bound method> = bound_method %.loc7_18.2, %specific_fn [concrete = constants.%bound_method]
  319. // CHECK:STDOUT: %Int.as.Copy.impl.Op.call: init %i32 = call %bound_method.loc7_18.2(%.loc7_18.2) [concrete = constants.%int_1]
  320. // CHECK:STDOUT: %.loc7_18.3: init %struct_type.x = struct_init (%Int.as.Copy.impl.Op.call) to %return [concrete = constants.%struct]
  321. // CHECK:STDOUT: %.loc7_22: init %struct_type.x = converted %impl.elem0.loc7_18.1, %.loc7_18.3 [concrete = constants.%struct]
  322. // CHECK:STDOUT: return %.loc7_22 to %return
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT: