import.carbon 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/generic/import.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/import.carbon
  10. // --- foo.carbon
  11. library "foo";
  12. class Class(T:! type);
  13. class CompleteClass(T:! type) {
  14. var n: i32;
  15. fn F() -> i32 { return 0; }
  16. }
  17. fn F() -> CompleteClass(i32);
  18. // --- foo.impl.carbon
  19. impl library "foo";
  20. class Class(T:! type) {
  21. var x: T;
  22. }
  23. fn F() -> CompleteClass(i32) {
  24. return {.n = 1};
  25. }
  26. // --- use_foo.carbon
  27. library "use_foo";
  28. import library "foo";
  29. fn UseMethod() -> i32 {
  30. var v: CompleteClass(i32) = F();
  31. return v.F();
  32. }
  33. fn UseField() -> i32 {
  34. var v: CompleteClass(i32) = F();
  35. return v.n;
  36. }
  37. // --- fail_generic_arg_mismatch.carbon
  38. library "fail_generic_arg_mismatch";
  39. import library "foo";
  40. fn Use() {
  41. // TODO: Include the generic arguments in the formatted type name.
  42. // CHECK:STDERR: fail_generic_arg_mismatch.carbon:[[@LINE+4]]:3: ERROR: Cannot implicitly convert from `CompleteClass` to `CompleteClass`.
  43. // CHECK:STDERR: var v: CompleteClass(i32*) = F();
  44. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  45. // CHECK:STDERR:
  46. var v: CompleteClass(i32*) = F();
  47. }
  48. // --- fail_bad_foo.impl.carbon
  49. impl library "foo";
  50. // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+10]]:13: ERROR: Redeclaration differs at parameter 1.
  51. // CHECK:STDERR: class Class(U:! type) {
  52. // CHECK:STDERR: ^
  53. // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE-5]]:6: In import.
  54. // CHECK:STDERR: impl library "foo";
  55. // CHECK:STDERR: ^~~~~~~
  56. // CHECK:STDERR: foo.carbon:4:13: Previous declaration's corresponding parameter here.
  57. // CHECK:STDERR: class Class(T:! type);
  58. // CHECK:STDERR: ^
  59. // CHECK:STDERR:
  60. class Class(U:! type) {
  61. // CHECK:STDERR: fail_bad_foo.impl.carbon:[[@LINE+3]]:10: ERROR: Name `T` not found.
  62. // CHECK:STDERR: var x: T;
  63. // CHECK:STDERR: ^
  64. var x: T;
  65. }
  66. // CHECK:STDOUT: --- foo.carbon
  67. // CHECK:STDOUT:
  68. // CHECK:STDOUT: constants {
  69. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  70. // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template]
  71. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  72. // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template]
  73. // CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic]
  74. // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template]
  75. // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template]
  76. // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic]
  77. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  78. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  79. // CHECK:STDOUT: %.2: type = unbound_element_type %CompleteClass.2, i32 [symbolic]
  80. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic]
  81. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic]
  82. // CHECK:STDOUT: %.3: type = struct_type {.n: i32} [template]
  83. // CHECK:STDOUT: %.4: i32 = int_literal 0 [template]
  84. // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template]
  85. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  86. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: imports {
  90. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  91. // CHECK:STDOUT: .Int32 = %import_ref
  92. // CHECK:STDOUT: import Core//prelude
  93. // CHECK:STDOUT: import Core//prelude/operators
  94. // CHECK:STDOUT: import Core//prelude/types
  95. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  96. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  97. // CHECK:STDOUT: import Core//prelude/operators/comparison
  98. // CHECK:STDOUT: import Core//prelude/types/bool
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT:
  103. // CHECK:STDOUT: file {
  104. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  105. // CHECK:STDOUT: .Core = imports.%Core
  106. // CHECK:STDOUT: .Class = %Class.decl
  107. // CHECK:STDOUT: .CompleteClass = %CompleteClass.decl
  108. // CHECK:STDOUT: .F = %F.decl
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %Core.import = import Core
  111. // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] {
  112. // CHECK:STDOUT: %T.loc4_13.1: type = param T
  113. // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = @Class.%T (constants.%T)]
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: %CompleteClass.decl: %CompleteClass.type = class_decl @CompleteClass [template = constants.%CompleteClass.1] {
  116. // CHECK:STDOUT: %T.loc6_21.1: type = param T
  117. // CHECK:STDOUT: %T.loc6_21.2: type = bind_symbolic_name T 0, %T.loc6_21.1 [symbolic = @CompleteClass.%T (constants.%T)]
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  120. // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, %CompleteClass.decl [template = constants.%CompleteClass.1]
  121. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  122. // CHECK:STDOUT: %.loc11_24.1: type = value_of_initializer %int.make_type_32 [template = i32]
  123. // CHECK:STDOUT: %.loc11_24.2: type = converted %int.make_type_32, %.loc11_24.1 [template = i32]
  124. // CHECK:STDOUT: %.loc11_24.3: init type = call %CompleteClass.ref(%.loc11_24.2) [template = constants.%CompleteClass.3]
  125. // CHECK:STDOUT: %.loc11_28.1: type = value_of_initializer %.loc11_24.3 [template = constants.%CompleteClass.3]
  126. // CHECK:STDOUT: %.loc11_28.2: type = converted %.loc11_24.3, %.loc11_28.1 [template = constants.%CompleteClass.3]
  127. // CHECK:STDOUT: @F.2.%return: ref %CompleteClass.3 = var <return slot>
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: generic class @Class(file.%T.loc4_13.2: type) {
  132. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: class;
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: generic class @CompleteClass(file.%T.loc6_21.2: type) {
  138. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: !definition:
  141. // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)]
  142. // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.2)]
  143. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)]
  144. // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)]
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: class {
  147. // CHECK:STDOUT: %int.make_type_32.loc7: init type = call constants.%Int32() [template = i32]
  148. // CHECK:STDOUT: %.loc7_10.1: type = value_of_initializer %int.make_type_32.loc7 [template = i32]
  149. // CHECK:STDOUT: %.loc7_10.2: type = converted %int.make_type_32.loc7, %.loc7_10.1 [template = i32]
  150. // CHECK:STDOUT: %.loc7_8: @CompleteClass.%.1 (%.2) = field_decl n, element0 [template]
  151. // CHECK:STDOUT: %F.decl: @CompleteClass.%F.type (%F.type.1) = fn_decl @F.1 [symbolic = %F (constants.%F.1)] {
  152. // CHECK:STDOUT: %int.make_type_32.loc8: init type = call constants.%Int32() [template = i32]
  153. // CHECK:STDOUT: %.loc8_13.1: type = value_of_initializer %int.make_type_32.loc8 [template = i32]
  154. // CHECK:STDOUT: %.loc8_13.2: type = converted %int.make_type_32.loc8, %.loc8_13.1 [template = i32]
  155. // CHECK:STDOUT: %return.var: ref i32 = var <return slot>
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !members:
  159. // CHECK:STDOUT: .Self = constants.%CompleteClass.2
  160. // CHECK:STDOUT: .n = %.loc7_8
  161. // CHECK:STDOUT: .F = %F.decl
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: generic fn @F.1(file.%T.loc6_21.2: type) {
  168. // CHECK:STDOUT: !definition:
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: fn() -> i32 {
  171. // CHECK:STDOUT: !entry:
  172. // CHECK:STDOUT: %.loc8: i32 = int_literal 0 [template = constants.%.4]
  173. // CHECK:STDOUT: return %.loc8
  174. // CHECK:STDOUT: }
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: fn @F.2() -> %CompleteClass.3;
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: specific @Class(constants.%T) {
  180. // CHECK:STDOUT: %T => constants.%T
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: specific @CompleteClass(constants.%T) {
  184. // CHECK:STDOUT: %T => constants.%T
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: specific @F.1(constants.%T) {}
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) {
  190. // CHECK:STDOUT: %T => constants.%T
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: specific @CompleteClass(i32) {
  194. // CHECK:STDOUT: %T => i32
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: --- foo.impl.carbon
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: constants {
  200. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  201. // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template]
  202. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  203. // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template]
  204. // CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic]
  205. // CHECK:STDOUT: %.2: type = unbound_element_type %Class.2, %T [symbolic]
  206. // CHECK:STDOUT: %.3: type = struct_type {.x: %T} [symbolic]
  207. // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template]
  208. // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template]
  209. // CHECK:STDOUT: %.4: type = struct_type {.n: i32} [template]
  210. // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic]
  211. // CHECK:STDOUT: %.5: type = unbound_element_type %CompleteClass.2, i32 [symbolic]
  212. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic]
  213. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic]
  214. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  215. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  216. // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template]
  217. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  218. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  219. // CHECK:STDOUT: %.6: type = unbound_element_type %CompleteClass.3, i32 [template]
  220. // CHECK:STDOUT: %F.type.3: type = fn_type @F.1, @CompleteClass(i32) [template]
  221. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  222. // CHECK:STDOUT: %.7: type = ptr_type %.4 [template]
  223. // CHECK:STDOUT: %.8: i32 = int_literal 1 [template]
  224. // CHECK:STDOUT: %struct: %CompleteClass.3 = struct_value (%.8) [template]
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: imports {
  228. // CHECK:STDOUT: %import_ref.1: %Class.type = import_ref Main//foo, inst+6, loaded [template = constants.%Class.1]
  229. // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+14, loaded [template = constants.%CompleteClass.1]
  230. // CHECK:STDOUT: %import_ref.3: %F.type.2 = import_ref Main//foo, inst+55, loaded [template = constants.%F.2]
  231. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  232. // CHECK:STDOUT: .Int32 = %import_ref.7
  233. // CHECK:STDOUT: import Core//prelude
  234. // CHECK:STDOUT: import Core//prelude/operators
  235. // CHECK:STDOUT: import Core//prelude/types
  236. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  237. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  238. // CHECK:STDOUT: import Core//prelude/operators/comparison
  239. // CHECK:STDOUT: import Core//prelude/types/bool
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+18, unloaded
  242. // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+28, unloaded
  243. // CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+35, unloaded
  244. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: file {
  248. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  249. // CHECK:STDOUT: .Class = %Class.decl
  250. // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2
  251. // CHECK:STDOUT: .F = %F.decl
  252. // CHECK:STDOUT: .Core = imports.%Core
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  255. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  256. // CHECK:STDOUT: %Core.import = import Core
  257. // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] {
  258. // CHECK:STDOUT: %T.loc4_13.1: type = param T
  259. // CHECK:STDOUT: %T.loc4_13.2: type = bind_symbolic_name T 0, %T.loc4_13.1 [symbolic = constants.%T]
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  262. // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1]
  263. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  264. // CHECK:STDOUT: %.loc8_24.1: type = value_of_initializer %int.make_type_32 [template = i32]
  265. // CHECK:STDOUT: %.loc8_24.2: type = converted %int.make_type_32, %.loc8_24.1 [template = i32]
  266. // CHECK:STDOUT: %.loc8_24.3: init type = call %CompleteClass.ref(%.loc8_24.2) [template = constants.%CompleteClass.3]
  267. // CHECK:STDOUT: %.loc8_28.1: type = value_of_initializer %.loc8_24.3 [template = constants.%CompleteClass.3]
  268. // CHECK:STDOUT: %.loc8_28.2: type = converted %.loc8_24.3, %.loc8_28.1 [template = constants.%CompleteClass.3]
  269. // CHECK:STDOUT: @F.2.%return: ref %CompleteClass.3 = var <return slot>
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: generic class @Class(constants.%T: type) {
  274. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: !definition:
  277. // CHECK:STDOUT: %Class: type = class_type @Class, @Class(%T) [symbolic = %Class (constants.%Class.2)]
  278. // CHECK:STDOUT: %.1: type = unbound_element_type @Class.%Class (%Class.2), @Class.%T (%T) [symbolic = %.1 (constants.%.2)]
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: class {
  281. // CHECK:STDOUT: %T.ref: type = name_ref T, file.%T.loc4_13.2 [symbolic = %T (constants.%T)]
  282. // CHECK:STDOUT: %.loc5: @Class.%.1 (%.2) = field_decl x, element0 [template]
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: !members:
  285. // CHECK:STDOUT: .Self = constants.%Class.2
  286. // CHECK:STDOUT: .x = %.loc5
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT: }
  289. // CHECK:STDOUT:
  290. // CHECK:STDOUT: generic class @CompleteClass(constants.%T: type) {
  291. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: !definition:
  294. // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)]
  295. // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.5)]
  296. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)]
  297. // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)]
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: class {
  300. // CHECK:STDOUT: !members:
  301. // CHECK:STDOUT: .Self = imports.%import_ref.4
  302. // CHECK:STDOUT: .n = imports.%import_ref.5
  303. // CHECK:STDOUT: .F = imports.%import_ref.6
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: generic fn @F.1(constants.%T: type) {
  308. // CHECK:STDOUT: !definition:
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: fn() -> i32;
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: fn @F.2() -> %return: %CompleteClass.3 {
  316. // CHECK:STDOUT: !entry:
  317. // CHECK:STDOUT: %.loc9_16: i32 = int_literal 1 [template = constants.%.8]
  318. // CHECK:STDOUT: %.loc9_17.1: %.4 = struct_literal (%.loc9_16)
  319. // CHECK:STDOUT: %.loc9_17.2: ref i32 = class_element_access %return, element0
  320. // CHECK:STDOUT: %.loc9_17.3: init i32 = initialize_from %.loc9_16 to %.loc9_17.2 [template = constants.%.8]
  321. // CHECK:STDOUT: %.loc9_17.4: init %CompleteClass.3 = class_init (%.loc9_17.3), %return [template = constants.%struct]
  322. // CHECK:STDOUT: %.loc9_18: init %CompleteClass.3 = converted %.loc9_17.1, %.loc9_17.4 [template = constants.%struct]
  323. // CHECK:STDOUT: return %.loc9_18 to %return
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: specific @Class(constants.%T) {
  327. // CHECK:STDOUT: %T => constants.%T
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: specific @Class(@Class.%T) {
  331. // CHECK:STDOUT: %T => constants.%T
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: specific @CompleteClass(constants.%T) {
  335. // CHECK:STDOUT: %T => constants.%T
  336. // CHECK:STDOUT: }
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) {
  339. // CHECK:STDOUT: %T => constants.%T
  340. // CHECK:STDOUT: }
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: specific @F.1(constants.%T) {}
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: specific @CompleteClass(i32) {
  345. // CHECK:STDOUT: %T => i32
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: !definition:
  348. // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3
  349. // CHECK:STDOUT: %.1 => constants.%.6
  350. // CHECK:STDOUT: %F.type => constants.%F.type.3
  351. // CHECK:STDOUT: %F => constants.%F.3
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: --- use_foo.carbon
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: constants {
  357. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  358. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  359. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  360. // CHECK:STDOUT: %UseMethod.type: type = fn_type @UseMethod [template]
  361. // CHECK:STDOUT: %UseMethod: %UseMethod.type = struct_value () [template]
  362. // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template]
  363. // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template]
  364. // CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template]
  365. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  366. // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic]
  367. // CHECK:STDOUT: %.3: type = unbound_element_type %CompleteClass.2, i32 [symbolic]
  368. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic]
  369. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic]
  370. // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(i32) [template]
  371. // CHECK:STDOUT: %.4: type = unbound_element_type %CompleteClass.3, i32 [template]
  372. // CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @CompleteClass(i32) [template]
  373. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  374. // CHECK:STDOUT: %.5: type = ptr_type %.2 [template]
  375. // CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template]
  376. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  377. // CHECK:STDOUT: %UseField.type: type = fn_type @UseField [template]
  378. // CHECK:STDOUT: %UseField: %UseField.type = struct_value () [template]
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: imports {
  382. // CHECK:STDOUT: %import_ref.1 = import_ref Main//foo, inst+6, unloaded
  383. // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+14, loaded [template = constants.%CompleteClass.1]
  384. // CHECK:STDOUT: %import_ref.3: %F.type.3 = import_ref Main//foo, inst+55, loaded [template = constants.%F.3]
  385. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  386. // CHECK:STDOUT: .Int32 = %import_ref.4
  387. // CHECK:STDOUT: import Core//prelude
  388. // CHECK:STDOUT: import Core//prelude/operators
  389. // CHECK:STDOUT: import Core//prelude/types
  390. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  391. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  392. // CHECK:STDOUT: import Core//prelude/operators/comparison
  393. // CHECK:STDOUT: import Core//prelude/types/bool
  394. // CHECK:STDOUT: }
  395. // CHECK:STDOUT: %import_ref.4: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  396. // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+18, unloaded
  397. // CHECK:STDOUT: %import_ref.6: @CompleteClass.%.1 (%.3) = import_ref Main//foo, inst+28, loaded [template = %.1]
  398. // CHECK:STDOUT: %import_ref.7: @CompleteClass.%F.type (%F.type.1) = import_ref Main//foo, inst+35, loaded [symbolic = @CompleteClass.%F (constants.%F.1)]
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: file {
  402. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  403. // CHECK:STDOUT: .Class = imports.%import_ref.1
  404. // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2
  405. // CHECK:STDOUT: .F = imports.%import_ref.3
  406. // CHECK:STDOUT: .Core = imports.%Core
  407. // CHECK:STDOUT: .UseMethod = %UseMethod.decl
  408. // CHECK:STDOUT: .UseField = %UseField.decl
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT: %Core.import = import Core
  411. // CHECK:STDOUT: %default.import = import <invalid>
  412. // CHECK:STDOUT: %UseMethod.decl: %UseMethod.type = fn_decl @UseMethod [template = constants.%UseMethod] {
  413. // CHECK:STDOUT: %int.make_type_32.loc5: init type = call constants.%Int32() [template = i32]
  414. // CHECK:STDOUT: %.loc5_19.1: type = value_of_initializer %int.make_type_32.loc5 [template = i32]
  415. // CHECK:STDOUT: %.loc5_19.2: type = converted %int.make_type_32.loc5, %.loc5_19.1 [template = i32]
  416. // CHECK:STDOUT: @UseMethod.%return: ref i32 = var <return slot>
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT: %UseField.decl: %UseField.type = fn_decl @UseField [template = constants.%UseField] {
  419. // CHECK:STDOUT: %int.make_type_32.loc10: init type = call constants.%Int32() [template = i32]
  420. // CHECK:STDOUT: %.loc10_18.1: type = value_of_initializer %int.make_type_32.loc10 [template = i32]
  421. // CHECK:STDOUT: %.loc10_18.2: type = converted %int.make_type_32.loc10, %.loc10_18.1 [template = i32]
  422. // CHECK:STDOUT: @UseField.%return: ref i32 = var <return slot>
  423. // CHECK:STDOUT: }
  424. // CHECK:STDOUT: }
  425. // CHECK:STDOUT:
  426. // CHECK:STDOUT: generic class @CompleteClass(constants.%T: type) {
  427. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: !definition:
  430. // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)]
  431. // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.3)]
  432. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)]
  433. // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)]
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: class {
  436. // CHECK:STDOUT: !members:
  437. // CHECK:STDOUT: .Self = imports.%import_ref.5
  438. // CHECK:STDOUT: .n = imports.%import_ref.6
  439. // CHECK:STDOUT: .F = imports.%import_ref.7
  440. // CHECK:STDOUT: }
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: fn @UseMethod() -> i32 {
  446. // CHECK:STDOUT: !entry:
  447. // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1]
  448. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  449. // CHECK:STDOUT: %.loc6_23.1: type = value_of_initializer %int.make_type_32 [template = i32]
  450. // CHECK:STDOUT: %.loc6_23.2: type = converted %int.make_type_32, %.loc6_23.1 [template = i32]
  451. // CHECK:STDOUT: %.loc6_23.3: init type = call %CompleteClass.ref(%.loc6_23.2) [template = constants.%CompleteClass.3]
  452. // CHECK:STDOUT: %.loc6_27.1: type = value_of_initializer %.loc6_23.3 [template = constants.%CompleteClass.3]
  453. // CHECK:STDOUT: %.loc6_27.2: type = converted %.loc6_23.3, %.loc6_27.1 [template = constants.%CompleteClass.3]
  454. // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v
  455. // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var
  456. // CHECK:STDOUT: %F.ref.loc6: %F.type.3 = name_ref F, imports.%import_ref.3 [template = constants.%F.3]
  457. // CHECK:STDOUT: %.loc6_7: ref %CompleteClass.3 = splice_block %v.var {}
  458. // CHECK:STDOUT: %F.call.loc6: init %CompleteClass.3 = call %F.ref.loc6() to %.loc6_7
  459. // CHECK:STDOUT: assign %v.var, %F.call.loc6
  460. // CHECK:STDOUT: %v.ref: ref %CompleteClass.3 = name_ref v, %v
  461. // CHECK:STDOUT: %.loc7_11: %F.type.2 = specific_constant imports.%import_ref.7, @CompleteClass(i32) [template = constants.%F.2]
  462. // CHECK:STDOUT: %F.ref.loc7: %F.type.2 = name_ref F, %.loc7_11 [template = constants.%F.2]
  463. // CHECK:STDOUT: %F.call.loc7: init i32 = call %F.ref.loc7()
  464. // CHECK:STDOUT: %.loc7_15.1: i32 = value_of_initializer %F.call.loc7
  465. // CHECK:STDOUT: %.loc7_15.2: i32 = converted %F.call.loc7, %.loc7_15.1
  466. // CHECK:STDOUT: return %.loc7_15.2
  467. // CHECK:STDOUT: }
  468. // CHECK:STDOUT:
  469. // CHECK:STDOUT: generic fn @F.1(constants.%T: type) {
  470. // CHECK:STDOUT: !definition:
  471. // CHECK:STDOUT:
  472. // CHECK:STDOUT: fn() -> i32;
  473. // CHECK:STDOUT: }
  474. // CHECK:STDOUT:
  475. // CHECK:STDOUT: fn @F.2() -> %CompleteClass.3;
  476. // CHECK:STDOUT:
  477. // CHECK:STDOUT: fn @UseField() -> i32 {
  478. // CHECK:STDOUT: !entry:
  479. // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1]
  480. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  481. // CHECK:STDOUT: %.loc11_23.1: type = value_of_initializer %int.make_type_32 [template = i32]
  482. // CHECK:STDOUT: %.loc11_23.2: type = converted %int.make_type_32, %.loc11_23.1 [template = i32]
  483. // CHECK:STDOUT: %.loc11_23.3: init type = call %CompleteClass.ref(%.loc11_23.2) [template = constants.%CompleteClass.3]
  484. // CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %.loc11_23.3 [template = constants.%CompleteClass.3]
  485. // CHECK:STDOUT: %.loc11_27.2: type = converted %.loc11_23.3, %.loc11_27.1 [template = constants.%CompleteClass.3]
  486. // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v
  487. // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var
  488. // CHECK:STDOUT: %F.ref: %F.type.3 = name_ref F, imports.%import_ref.3 [template = constants.%F.3]
  489. // CHECK:STDOUT: %.loc11_7: ref %CompleteClass.3 = splice_block %v.var {}
  490. // CHECK:STDOUT: %F.call: init %CompleteClass.3 = call %F.ref() to %.loc11_7
  491. // CHECK:STDOUT: assign %v.var, %F.call
  492. // CHECK:STDOUT: %v.ref: ref %CompleteClass.3 = name_ref v, %v
  493. // CHECK:STDOUT: %n.ref: %.4 = name_ref n, imports.%import_ref.6 [template = imports.%.1]
  494. // CHECK:STDOUT: %.loc12_11.1: ref i32 = class_element_access %v.ref, element0
  495. // CHECK:STDOUT: %.loc12_11.2: i32 = bind_value %.loc12_11.1
  496. // CHECK:STDOUT: return %.loc12_11.2
  497. // CHECK:STDOUT: }
  498. // CHECK:STDOUT:
  499. // CHECK:STDOUT: specific @CompleteClass(constants.%T) {
  500. // CHECK:STDOUT: %T => constants.%T
  501. // CHECK:STDOUT: }
  502. // CHECK:STDOUT:
  503. // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) {
  504. // CHECK:STDOUT: %T => constants.%T
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: specific @F.1(constants.%T) {}
  508. // CHECK:STDOUT:
  509. // CHECK:STDOUT: specific @CompleteClass(i32) {
  510. // CHECK:STDOUT: %T => i32
  511. // CHECK:STDOUT:
  512. // CHECK:STDOUT: !definition:
  513. // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3
  514. // CHECK:STDOUT: %.1 => constants.%.4
  515. // CHECK:STDOUT: %F.type => constants.%F.type.2
  516. // CHECK:STDOUT: %F => constants.%F.2
  517. // CHECK:STDOUT: }
  518. // CHECK:STDOUT:
  519. // CHECK:STDOUT: specific @F.1(i32) {}
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: --- fail_generic_arg_mismatch.carbon
  522. // CHECK:STDOUT:
  523. // CHECK:STDOUT: constants {
  524. // CHECK:STDOUT: %Use.type: type = fn_type @Use [template]
  525. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  526. // CHECK:STDOUT: %Use: %Use.type = struct_value () [template]
  527. // CHECK:STDOUT: %CompleteClass.type: type = generic_class_type @CompleteClass [template]
  528. // CHECK:STDOUT: %CompleteClass.1: %CompleteClass.type = struct_value () [template]
  529. // CHECK:STDOUT: %.2: type = struct_type {.n: i32} [template]
  530. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  531. // CHECK:STDOUT: %CompleteClass.2: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic]
  532. // CHECK:STDOUT: %.3: type = unbound_element_type %CompleteClass.2, i32 [symbolic]
  533. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @CompleteClass(%T) [symbolic]
  534. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic]
  535. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  536. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  537. // CHECK:STDOUT: %.4: type = ptr_type i32 [template]
  538. // CHECK:STDOUT: %CompleteClass.3: type = class_type @CompleteClass, @CompleteClass(%.4) [template]
  539. // CHECK:STDOUT: %.5: type = unbound_element_type %CompleteClass.3, i32 [template]
  540. // CHECK:STDOUT: %F.type.2: type = fn_type @F.1, @CompleteClass(%.4) [template]
  541. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  542. // CHECK:STDOUT: %.6: type = ptr_type %.2 [template]
  543. // CHECK:STDOUT: %F.type.3: type = fn_type @F.2 [template]
  544. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  545. // CHECK:STDOUT: %CompleteClass.4: type = class_type @CompleteClass, @CompleteClass(i32) [template]
  546. // CHECK:STDOUT: %.7: type = unbound_element_type %CompleteClass.4, i32 [template]
  547. // CHECK:STDOUT: %F.type.4: type = fn_type @F.1, @CompleteClass(i32) [template]
  548. // CHECK:STDOUT: %F.4: %F.type.4 = struct_value () [template]
  549. // CHECK:STDOUT: }
  550. // CHECK:STDOUT:
  551. // CHECK:STDOUT: imports {
  552. // CHECK:STDOUT: %import_ref.1 = import_ref Main//foo, inst+6, unloaded
  553. // CHECK:STDOUT: %import_ref.2: %CompleteClass.type = import_ref Main//foo, inst+14, loaded [template = constants.%CompleteClass.1]
  554. // CHECK:STDOUT: %import_ref.3: %F.type.3 = import_ref Main//foo, inst+55, loaded [template = constants.%F.3]
  555. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  556. // CHECK:STDOUT: .Int32 = %import_ref.7
  557. // CHECK:STDOUT: import Core//prelude
  558. // CHECK:STDOUT: import Core//prelude/operators
  559. // CHECK:STDOUT: import Core//prelude/types
  560. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  561. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  562. // CHECK:STDOUT: import Core//prelude/operators/comparison
  563. // CHECK:STDOUT: import Core//prelude/types/bool
  564. // CHECK:STDOUT: }
  565. // CHECK:STDOUT: %import_ref.4 = import_ref Main//foo, inst+18, unloaded
  566. // CHECK:STDOUT: %import_ref.5 = import_ref Main//foo, inst+28, unloaded
  567. // CHECK:STDOUT: %import_ref.6 = import_ref Main//foo, inst+35, unloaded
  568. // CHECK:STDOUT: %import_ref.7: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  569. // CHECK:STDOUT: }
  570. // CHECK:STDOUT:
  571. // CHECK:STDOUT: file {
  572. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  573. // CHECK:STDOUT: .Class = imports.%import_ref.1
  574. // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2
  575. // CHECK:STDOUT: .F = imports.%import_ref.3
  576. // CHECK:STDOUT: .Core = imports.%Core
  577. // CHECK:STDOUT: .Use = %Use.decl
  578. // CHECK:STDOUT: }
  579. // CHECK:STDOUT: %Core.import = import Core
  580. // CHECK:STDOUT: %default.import = import <invalid>
  581. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [template = constants.%Use] {}
  582. // CHECK:STDOUT: }
  583. // CHECK:STDOUT:
  584. // CHECK:STDOUT: generic class @CompleteClass(constants.%T: type) {
  585. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  586. // CHECK:STDOUT:
  587. // CHECK:STDOUT: !definition:
  588. // CHECK:STDOUT: %CompleteClass: type = class_type @CompleteClass, @CompleteClass(%T) [symbolic = %CompleteClass (constants.%CompleteClass.2)]
  589. // CHECK:STDOUT: %.1: type = unbound_element_type @CompleteClass.%CompleteClass (%CompleteClass.2), i32 [symbolic = %.1 (constants.%.3)]
  590. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @CompleteClass(%T) [symbolic = %F.type (constants.%F.type.1)]
  591. // CHECK:STDOUT: %F: @CompleteClass.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)]
  592. // CHECK:STDOUT:
  593. // CHECK:STDOUT: class {
  594. // CHECK:STDOUT: !members:
  595. // CHECK:STDOUT: .Self = imports.%import_ref.4
  596. // CHECK:STDOUT: .n = imports.%import_ref.5
  597. // CHECK:STDOUT: .F = imports.%import_ref.6
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT: }
  600. // CHECK:STDOUT:
  601. // CHECK:STDOUT: fn @Use() {
  602. // CHECK:STDOUT: !entry:
  603. // CHECK:STDOUT: %CompleteClass.ref: %CompleteClass.type = name_ref CompleteClass, imports.%import_ref.2 [template = constants.%CompleteClass.1]
  604. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  605. // CHECK:STDOUT: %.loc11_27.1: type = value_of_initializer %int.make_type_32 [template = i32]
  606. // CHECK:STDOUT: %.loc11_27.2: type = converted %int.make_type_32, %.loc11_27.1 [template = i32]
  607. // CHECK:STDOUT: %.loc11_27.3: type = ptr_type i32 [template = constants.%.4]
  608. // CHECK:STDOUT: %.loc11_23: init type = call %CompleteClass.ref(%.loc11_27.3) [template = constants.%CompleteClass.3]
  609. // CHECK:STDOUT: %.loc11_28.1: type = value_of_initializer %.loc11_23 [template = constants.%CompleteClass.3]
  610. // CHECK:STDOUT: %.loc11_28.2: type = converted %.loc11_23, %.loc11_28.1 [template = constants.%CompleteClass.3]
  611. // CHECK:STDOUT: %v.var: ref %CompleteClass.3 = var v
  612. // CHECK:STDOUT: %v: ref %CompleteClass.3 = bind_name v, %v.var
  613. // CHECK:STDOUT: %F.ref: %F.type.3 = name_ref F, imports.%import_ref.3 [template = constants.%F.3]
  614. // CHECK:STDOUT: %.loc11_33: ref %CompleteClass.4 = temporary_storage
  615. // CHECK:STDOUT: %F.call: init %CompleteClass.4 = call %F.ref() to %.loc11_33
  616. // CHECK:STDOUT: assign %v.var, <error>
  617. // CHECK:STDOUT: return
  618. // CHECK:STDOUT: }
  619. // CHECK:STDOUT:
  620. // CHECK:STDOUT: generic fn @F.1(constants.%T: type) {
  621. // CHECK:STDOUT: !definition:
  622. // CHECK:STDOUT:
  623. // CHECK:STDOUT: fn() -> i32;
  624. // CHECK:STDOUT: }
  625. // CHECK:STDOUT:
  626. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  627. // CHECK:STDOUT:
  628. // CHECK:STDOUT: fn @F.2() -> %CompleteClass.4;
  629. // CHECK:STDOUT:
  630. // CHECK:STDOUT: specific @CompleteClass(constants.%T) {
  631. // CHECK:STDOUT: %T => constants.%T
  632. // CHECK:STDOUT: }
  633. // CHECK:STDOUT:
  634. // CHECK:STDOUT: specific @CompleteClass(@CompleteClass.%T) {
  635. // CHECK:STDOUT: %T => constants.%T
  636. // CHECK:STDOUT: }
  637. // CHECK:STDOUT:
  638. // CHECK:STDOUT: specific @F.1(constants.%T) {}
  639. // CHECK:STDOUT:
  640. // CHECK:STDOUT: specific @CompleteClass(constants.%.4) {
  641. // CHECK:STDOUT: %T => constants.%.4
  642. // CHECK:STDOUT:
  643. // CHECK:STDOUT: !definition:
  644. // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.3
  645. // CHECK:STDOUT: %.1 => constants.%.5
  646. // CHECK:STDOUT: %F.type => constants.%F.type.2
  647. // CHECK:STDOUT: %F => constants.%F.2
  648. // CHECK:STDOUT: }
  649. // CHECK:STDOUT:
  650. // CHECK:STDOUT: specific @CompleteClass(i32) {
  651. // CHECK:STDOUT: %T => i32
  652. // CHECK:STDOUT:
  653. // CHECK:STDOUT: !definition:
  654. // CHECK:STDOUT: %CompleteClass => constants.%CompleteClass.4
  655. // CHECK:STDOUT: %.1 => constants.%.7
  656. // CHECK:STDOUT: %F.type => constants.%F.type.4
  657. // CHECK:STDOUT: %F => constants.%F.4
  658. // CHECK:STDOUT: }
  659. // CHECK:STDOUT:
  660. // CHECK:STDOUT: --- fail_bad_foo.impl.carbon
  661. // CHECK:STDOUT:
  662. // CHECK:STDOUT: constants {
  663. // CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic]
  664. // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template]
  665. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  666. // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template]
  667. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  668. // CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic]
  669. // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template]
  670. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  671. // CHECK:STDOUT: %.3: type = class_type @.1, @.1(%U) [symbolic]
  672. // CHECK:STDOUT: }
  673. // CHECK:STDOUT:
  674. // CHECK:STDOUT: imports {
  675. // CHECK:STDOUT: %import_ref.1: %Class.type = import_ref Main//foo, inst+6, loaded [template = constants.%Class.1]
  676. // CHECK:STDOUT: %import_ref.2 = import_ref Main//foo, inst+14, unloaded
  677. // CHECK:STDOUT: %import_ref.3 = import_ref Main//foo, inst+55, unloaded
  678. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  679. // CHECK:STDOUT: import Core//prelude
  680. // CHECK:STDOUT: import Core//prelude/operators
  681. // CHECK:STDOUT: import Core//prelude/types
  682. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  683. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  684. // CHECK:STDOUT: import Core//prelude/operators/comparison
  685. // CHECK:STDOUT: import Core//prelude/types/bool
  686. // CHECK:STDOUT: }
  687. // CHECK:STDOUT: }
  688. // CHECK:STDOUT:
  689. // CHECK:STDOUT: file {
  690. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  691. // CHECK:STDOUT: .Class = imports.%import_ref.1
  692. // CHECK:STDOUT: .CompleteClass = imports.%import_ref.2
  693. // CHECK:STDOUT: .F = imports.%import_ref.3
  694. // CHECK:STDOUT: .Core = imports.%Core
  695. // CHECK:STDOUT: }
  696. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  697. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  698. // CHECK:STDOUT: %Core.import = import Core
  699. // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
  700. // CHECK:STDOUT: %U.loc14_13.1: type = param U
  701. // CHECK:STDOUT: %U.loc14_13.2: type = bind_symbolic_name U 0, %U.loc14_13.1 [symbolic = @.1.%U (constants.%U)]
  702. // CHECK:STDOUT: }
  703. // CHECK:STDOUT: }
  704. // CHECK:STDOUT:
  705. // CHECK:STDOUT: generic class @Class(constants.%T: type) {
  706. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T)]
  707. // CHECK:STDOUT:
  708. // CHECK:STDOUT: class;
  709. // CHECK:STDOUT: }
  710. // CHECK:STDOUT:
  711. // CHECK:STDOUT: generic class @.1(file.%U.loc14_13.2: type) {
  712. // CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic = %U (constants.%U)]
  713. // CHECK:STDOUT:
  714. // CHECK:STDOUT: !definition:
  715. // CHECK:STDOUT:
  716. // CHECK:STDOUT: class {
  717. // CHECK:STDOUT: %T.ref: <error> = name_ref T, <error> [template = <error>]
  718. // CHECK:STDOUT: %.loc18: <error> = field_decl x, element0 [template]
  719. // CHECK:STDOUT:
  720. // CHECK:STDOUT: !members:
  721. // CHECK:STDOUT: .Self = constants.%.3
  722. // CHECK:STDOUT: .x = %.loc18
  723. // CHECK:STDOUT: }
  724. // CHECK:STDOUT: }
  725. // CHECK:STDOUT:
  726. // CHECK:STDOUT: specific @Class(constants.%T) {
  727. // CHECK:STDOUT: %T => constants.%T
  728. // CHECK:STDOUT: }
  729. // CHECK:STDOUT:
  730. // CHECK:STDOUT: specific @.1(constants.%U) {
  731. // CHECK:STDOUT: %U => constants.%U
  732. // CHECK:STDOUT: }
  733. // CHECK:STDOUT: