import_generic.carbon 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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/impl/no_prelude/import_generic.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/import_generic.carbon
  10. // --- import_generic.carbon
  11. library "[[@TEST_NAME]]";
  12. class C {}
  13. interface I(T:! type) {}
  14. impl forall [T:! type] C as I(T);
  15. impl forall [T:! type] C as I(T*) {}
  16. // --- import_generic.impl.carbon
  17. impl library "[[@TEST_NAME]]";
  18. impl forall [T:! type] C as I(T) {}
  19. // --- fail_import_generic.impl.carbon
  20. impl library "[[@TEST_NAME]]";
  21. // CHECK:STDERR: fail_import_generic.impl.carbon:[[@LINE+7]]:1: error: redefinition of `impl C as I`
  22. // CHECK:STDERR: impl forall [T:! type] C as I(T*) {}
  23. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  24. // CHECK:STDERR: fail_import_generic.impl.carbon:[[@LINE-5]]:6: in import
  25. // CHECK:STDERR: import_generic.carbon:8:1: note: previous definition was here
  26. // CHECK:STDERR: impl forall [T:! type] C as I(T*) {}
  27. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28. impl forall [T:! type] C as I(T*) {}
  29. // CHECK:STDOUT: --- import_generic.carbon
  30. // CHECK:STDOUT:
  31. // CHECK:STDOUT: constants {
  32. // CHECK:STDOUT: %C: type = class_type @C [template]
  33. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  34. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  35. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  36. // CHECK:STDOUT: %T.patt.1: type = symbolic_binding_pattern T, 0 [symbolic]
  37. // CHECK:STDOUT: %I.type.1: type = generic_interface_type @I [template]
  38. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  39. // CHECK:STDOUT: %I: %I.type.1 = struct_value () [template]
  40. // CHECK:STDOUT: %I.type.2: type = interface_type @I, @I(%T) [symbolic]
  41. // CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic]
  42. // CHECK:STDOUT: %T.patt.2: type = symbolic_binding_pattern T, 0 [symbolic]
  43. // CHECK:STDOUT: %T.patt.3: type = symbolic_binding_pattern T, 0 [symbolic]
  44. // CHECK:STDOUT: %.4: type = ptr_type %T [symbolic]
  45. // CHECK:STDOUT: %I.type.3: type = interface_type @I, @I(%.4) [symbolic]
  46. // CHECK:STDOUT: %.5: <witness> = interface_witness () [template]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: file {
  50. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  51. // CHECK:STDOUT: .C = %C.decl
  52. // CHECK:STDOUT: .I = %I.decl
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  55. // CHECK:STDOUT: %I.decl: %I.type.1 = interface_decl @I [template = constants.%I] {
  56. // CHECK:STDOUT: %T.patt.loc5_13.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc5_13.2 (constants.%T.patt.1)]
  57. // CHECK:STDOUT: %T.param_patt: type = param_pattern %T.patt.loc5_13.1, runtime_param<invalid> [symbolic = %T.patt.loc5_13.2 (constants.%T.patt.1)]
  58. // CHECK:STDOUT: } {
  59. // CHECK:STDOUT: %param: type = param runtime_param<invalid>
  60. // CHECK:STDOUT: %T.loc5_13.1: type = bind_symbolic_name T, 0, %param [symbolic = %T.loc5_13.2 (constants.%T)]
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT: impl_decl @impl.1 [template] {
  63. // CHECK:STDOUT: %T.patt.loc7_14.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_14.2 (constants.%T.patt.2)]
  64. // CHECK:STDOUT: %T.param_patt: type = param_pattern %T.patt.loc7_14.1, runtime_param<invalid> [symbolic = %T.patt.loc7_14.2 (constants.%T.patt.2)]
  65. // CHECK:STDOUT: } {
  66. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  67. // CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, file.%I.decl [template = constants.%I]
  68. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc7_14.1 [symbolic = %T.loc7_14.2 (constants.%T)]
  69. // CHECK:STDOUT: %I.type.loc7_30.1: type = interface_type @I, @I(constants.%T) [symbolic = %I.type.loc7_30.2 (constants.%I.type.2)]
  70. // CHECK:STDOUT: %param: type = param runtime_param<invalid>
  71. // CHECK:STDOUT: %T.loc7_14.1: type = bind_symbolic_name T, 0, %param [symbolic = %T.loc7_14.2 (constants.%T)]
  72. // CHECK:STDOUT: }
  73. // CHECK:STDOUT: impl_decl @impl.2 [template] {
  74. // CHECK:STDOUT: %T.patt.loc8_14.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_14.2 (constants.%T.patt.3)]
  75. // CHECK:STDOUT: %T.param_patt: type = param_pattern %T.patt.loc8_14.1, runtime_param<invalid> [symbolic = %T.patt.loc8_14.2 (constants.%T.patt.3)]
  76. // CHECK:STDOUT: } {
  77. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  78. // CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, file.%I.decl [template = constants.%I]
  79. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc8_14.1 [symbolic = %T.loc8_14.2 (constants.%T)]
  80. // CHECK:STDOUT: %.loc8_32.1: type = ptr_type %T [symbolic = %.loc8_32.2 (constants.%.4)]
  81. // CHECK:STDOUT: %I.type.loc8_30.1: type = interface_type @I, @I(constants.%.4) [symbolic = %I.type.loc8_30.2 (constants.%I.type.3)]
  82. // CHECK:STDOUT: %param: type = param runtime_param<invalid>
  83. // CHECK:STDOUT: %T.loc8_14.1: type = bind_symbolic_name T, 0, %param [symbolic = %T.loc8_14.2 (constants.%T)]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: }
  86. // CHECK:STDOUT:
  87. // CHECK:STDOUT: generic interface @I(%T.loc5_13.1: type) {
  88. // CHECK:STDOUT: %T.loc5_13.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc5_13.2 (constants.%T)]
  89. // CHECK:STDOUT: %T.patt.loc5_13.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc5_13.2 (constants.%T.patt.1)]
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: !definition:
  92. // CHECK:STDOUT: %I.type: type = interface_type @I, @I(%T.loc5_13.2) [symbolic = %I.type (constants.%I.type.2)]
  93. // CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: interface {
  96. // CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  97. // CHECK:STDOUT:
  98. // CHECK:STDOUT: !members:
  99. // CHECK:STDOUT: .Self = %Self.1
  100. // CHECK:STDOUT: witness = ()
  101. // CHECK:STDOUT: }
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: generic impl @impl.1(%T.loc7_14.1: type) {
  105. // CHECK:STDOUT: %T.loc7_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc7_14.2 (constants.%T)]
  106. // CHECK:STDOUT: %T.patt.loc7_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_14.2 (constants.%T.patt.2)]
  107. // CHECK:STDOUT: %I.type.loc7_30.2: type = interface_type @I, @I(%T.loc7_14.2) [symbolic = %I.type.loc7_30.2 (constants.%I.type.2)]
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: impl: %C.ref as %I.type.loc7_30.1;
  110. // CHECK:STDOUT: }
  111. // CHECK:STDOUT:
  112. // CHECK:STDOUT: generic impl @impl.2(%T.loc8_14.1: type) {
  113. // CHECK:STDOUT: %T.loc8_14.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_14.2 (constants.%T)]
  114. // CHECK:STDOUT: %T.patt.loc8_14.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_14.2 (constants.%T.patt.3)]
  115. // CHECK:STDOUT: %.loc8_32.2: type = ptr_type @impl.2.%T.loc8_14.2 (%T) [symbolic = %.loc8_32.2 (constants.%.4)]
  116. // CHECK:STDOUT: %I.type.loc8_30.2: type = interface_type @I, @I(%.loc8_32.2) [symbolic = %I.type.loc8_30.2 (constants.%I.type.3)]
  117. // CHECK:STDOUT:
  118. // CHECK:STDOUT: !definition:
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: impl: %C.ref as %I.type.loc8_30.1 {
  121. // CHECK:STDOUT: %.loc8_35: <witness> = interface_witness () [template = constants.%.5]
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: !members:
  124. // CHECK:STDOUT: witness = %.loc8_35
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT:
  128. // CHECK:STDOUT: class @C {
  129. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: !members:
  132. // CHECK:STDOUT: .Self = constants.%C
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT:
  135. // CHECK:STDOUT: specific @I(constants.%T) {
  136. // CHECK:STDOUT: %T.loc5_13.2 => constants.%T
  137. // CHECK:STDOUT: %T.patt.loc5_13.2 => constants.%T
  138. // CHECK:STDOUT: }
  139. // CHECK:STDOUT:
  140. // CHECK:STDOUT: specific @I(@I.%T.loc5_13.2) {
  141. // CHECK:STDOUT: %T.loc5_13.2 => constants.%T
  142. // CHECK:STDOUT: %T.patt.loc5_13.2 => constants.%T
  143. // CHECK:STDOUT: }
  144. // CHECK:STDOUT:
  145. // CHECK:STDOUT: specific @I(@impl.1.%T.loc7_14.2) {
  146. // CHECK:STDOUT: %T.loc5_13.2 => constants.%T
  147. // CHECK:STDOUT: %T.patt.loc5_13.2 => constants.%T
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: specific @impl.1(constants.%T) {
  151. // CHECK:STDOUT: %T.loc7_14.2 => constants.%T
  152. // CHECK:STDOUT: %T.patt.loc7_14.2 => constants.%T
  153. // CHECK:STDOUT: %I.type.loc7_30.2 => constants.%I.type.2
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: specific @I(constants.%.4) {
  157. // CHECK:STDOUT: %T.loc5_13.2 => constants.%.4
  158. // CHECK:STDOUT: %T.patt.loc5_13.2 => constants.%.4
  159. // CHECK:STDOUT:
  160. // CHECK:STDOUT: !definition:
  161. // CHECK:STDOUT: %I.type => constants.%I.type.3
  162. // CHECK:STDOUT: %Self.2 => constants.%Self
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT:
  165. // CHECK:STDOUT: specific @I(@impl.2.%.loc8_32.2) {
  166. // CHECK:STDOUT: %T.loc5_13.2 => constants.%.4
  167. // CHECK:STDOUT: %T.patt.loc5_13.2 => constants.%.4
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: specific @impl.2(constants.%T) {
  171. // CHECK:STDOUT: %T.loc8_14.2 => constants.%T
  172. // CHECK:STDOUT: %T.patt.loc8_14.2 => constants.%T
  173. // CHECK:STDOUT: %.loc8_32.2 => constants.%.4
  174. // CHECK:STDOUT: %I.type.loc8_30.2 => constants.%I.type.3
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: --- import_generic.impl.carbon
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: constants {
  180. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  181. // CHECK:STDOUT: %I.type.1: type = generic_interface_type @I [template]
  182. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  183. // CHECK:STDOUT: %I: %I.type.1 = struct_value () [template]
  184. // CHECK:STDOUT: %I.type.2: type = interface_type @I, @I(%T) [symbolic]
  185. // CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic]
  186. // CHECK:STDOUT: %T.patt.1: type = symbolic_binding_pattern T, 0 [symbolic]
  187. // CHECK:STDOUT: %C: type = class_type @C [template]
  188. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  189. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  190. // CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic]
  191. // CHECK:STDOUT: %.4: type = ptr_type %T [symbolic]
  192. // CHECK:STDOUT: %I.type.3: type = interface_type @I, @I(%.4) [symbolic]
  193. // CHECK:STDOUT: %T.patt.2: type = symbolic_binding_pattern T, 0 [symbolic]
  194. // CHECK:STDOUT: %.5: <witness> = interface_witness () [template]
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: imports {
  198. // CHECK:STDOUT: %import_ref.1: type = import_ref Main//import_generic, inst+1, loaded [template = constants.%C]
  199. // CHECK:STDOUT: %import_ref.2: %I.type.1 = import_ref Main//import_generic, inst+12, loaded [template = constants.%I]
  200. // CHECK:STDOUT: %import_ref.3 = import_ref Main//import_generic, inst+19, unloaded
  201. // CHECK:STDOUT: %import_ref.4 = import_ref Main//import_generic, inst+2, unloaded
  202. // CHECK:STDOUT: %import_ref.5: type = import_ref Main//import_generic, inst+28, loaded [template = constants.%C]
  203. // CHECK:STDOUT: %import_ref.6: type = import_ref Main//import_generic, inst+31, loaded [symbolic = @impl.1.%I.type.1 (constants.%I.type.2)]
  204. // CHECK:STDOUT: %import_ref.7: type = import_ref Main//import_generic, inst+41, loaded [template = constants.%C]
  205. // CHECK:STDOUT: %import_ref.8: type = import_ref Main//import_generic, inst+46, loaded [symbolic = @impl.2.%I.type (constants.%I.type.3)]
  206. // CHECK:STDOUT: %import_ref.9 = import_ref Main//import_generic, inst+53, unloaded
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: file {
  210. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  211. // CHECK:STDOUT: .C = imports.%import_ref.1
  212. // CHECK:STDOUT: .I = imports.%import_ref.2
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  215. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  216. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  217. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C]
  218. // CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, imports.%import_ref.2 [template = constants.%I]
  219. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc4 [symbolic = constants.%T]
  220. // CHECK:STDOUT: %I.type.loc4: type = interface_type @I, @I(constants.%T) [symbolic = constants.%I.type.2]
  221. // CHECK:STDOUT: %param: type = param runtime_param<invalid>
  222. // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T, 0, %param [symbolic = constants.%T]
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: generic interface @I(constants.%T: type) {
  227. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  228. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt.1)]
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: !definition:
  231. // CHECK:STDOUT: %I.type: type = interface_type @I, @I(%T) [symbolic = %I.type (constants.%I.type.2)]
  232. // CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: interface {
  235. // CHECK:STDOUT: !members:
  236. // CHECK:STDOUT: .Self = imports.%import_ref.3
  237. // CHECK:STDOUT: witness = ()
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: generic impl @impl.1(constants.%T: type) {
  242. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  243. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt.1)]
  244. // CHECK:STDOUT: %I.type.1: type = interface_type @I, @I(%T.1) [symbolic = %I.type.1 (constants.%I.type.2)]
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: !definition:
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: impl: imports.%import_ref.5 as imports.%import_ref.6 {
  249. // CHECK:STDOUT: %.loc4: <witness> = interface_witness () [template = constants.%.5]
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: !members:
  252. // CHECK:STDOUT: witness = %.loc4
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: generic impl @impl.2(constants.%T: type) {
  257. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  258. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt.1)]
  259. // CHECK:STDOUT: %.1: type = ptr_type @impl.2.%T (%T) [symbolic = %.1 (constants.%.4)]
  260. // CHECK:STDOUT: %I.type: type = interface_type @I, @I(%.1) [symbolic = %I.type (constants.%I.type.3)]
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: !definition:
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: impl: imports.%import_ref.7 as imports.%import_ref.8 {
  265. // CHECK:STDOUT: !members:
  266. // CHECK:STDOUT: witness = imports.%import_ref.9
  267. // CHECK:STDOUT: }
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: class @C {
  271. // CHECK:STDOUT: !members:
  272. // CHECK:STDOUT: .Self = imports.%import_ref.4
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: specific @I(constants.%T) {
  276. // CHECK:STDOUT: %T => constants.%T
  277. // CHECK:STDOUT: %T.patt => constants.%T
  278. // CHECK:STDOUT:
  279. // CHECK:STDOUT: !definition:
  280. // CHECK:STDOUT: %I.type => constants.%I.type.2
  281. // CHECK:STDOUT: %Self => constants.%Self.2
  282. // CHECK:STDOUT: }
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: specific @I(@I.%T) {
  285. // CHECK:STDOUT: %T => constants.%T
  286. // CHECK:STDOUT: %T.patt => constants.%T
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: specific @I(@impl.1.%T.1) {
  290. // CHECK:STDOUT: %T => constants.%T
  291. // CHECK:STDOUT: %T.patt => constants.%T
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT:
  294. // CHECK:STDOUT: specific @impl.1(constants.%T) {
  295. // CHECK:STDOUT: %T.1 => constants.%T
  296. // CHECK:STDOUT: %T.patt => constants.%T
  297. // CHECK:STDOUT: %I.type.1 => constants.%I.type.2
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: specific @I(constants.%.4) {
  301. // CHECK:STDOUT: %T => constants.%.4
  302. // CHECK:STDOUT: %T.patt => constants.%.4
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: specific @I(@impl.2.%.1) {
  306. // CHECK:STDOUT: %T => constants.%.4
  307. // CHECK:STDOUT: %T.patt => constants.%.4
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: specific @impl.2(constants.%T) {
  311. // CHECK:STDOUT: %T => constants.%T
  312. // CHECK:STDOUT: %T.patt => constants.%T
  313. // CHECK:STDOUT: %.1 => constants.%.4
  314. // CHECK:STDOUT: %I.type => constants.%I.type.3
  315. // CHECK:STDOUT: }
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: --- fail_import_generic.impl.carbon
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: constants {
  320. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  321. // CHECK:STDOUT: %I.type.1: type = generic_interface_type @I [template]
  322. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  323. // CHECK:STDOUT: %I: %I.type.1 = struct_value () [template]
  324. // CHECK:STDOUT: %I.type.2: type = interface_type @I, @I(%T) [symbolic]
  325. // CHECK:STDOUT: %Self.1: @I.%I.type (%I.type.2) = bind_symbolic_name Self, 1 [symbolic]
  326. // CHECK:STDOUT: %T.patt.1: type = symbolic_binding_pattern T, 0 [symbolic]
  327. // CHECK:STDOUT: %C: type = class_type @C [template]
  328. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  329. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  330. // CHECK:STDOUT: %Self.2: %I.type.2 = bind_symbolic_name Self, 1 [symbolic]
  331. // CHECK:STDOUT: %.4: type = ptr_type %T [symbolic]
  332. // CHECK:STDOUT: %I.type.3: type = interface_type @I, @I(%.4) [symbolic]
  333. // CHECK:STDOUT: %T.patt.2: type = symbolic_binding_pattern T, 0 [symbolic]
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: imports {
  337. // CHECK:STDOUT: %import_ref.1: type = import_ref Main//import_generic, inst+1, loaded [template = constants.%C]
  338. // CHECK:STDOUT: %import_ref.2: %I.type.1 = import_ref Main//import_generic, inst+12, loaded [template = constants.%I]
  339. // CHECK:STDOUT: %import_ref.3 = import_ref Main//import_generic, inst+19, unloaded
  340. // CHECK:STDOUT: %import_ref.4 = import_ref Main//import_generic, inst+2, unloaded
  341. // CHECK:STDOUT: %import_ref.5: type = import_ref Main//import_generic, inst+28, loaded [template = constants.%C]
  342. // CHECK:STDOUT: %import_ref.6: type = import_ref Main//import_generic, inst+31, loaded [symbolic = @impl.1.%I.type (constants.%I.type.2)]
  343. // CHECK:STDOUT: %import_ref.7: type = import_ref Main//import_generic, inst+41, loaded [template = constants.%C]
  344. // CHECK:STDOUT: %import_ref.8: type = import_ref Main//import_generic, inst+46, loaded [symbolic = @impl.2.%I.type.1 (constants.%I.type.3)]
  345. // CHECK:STDOUT: %import_ref.9 = import_ref Main//import_generic, inst+53, unloaded
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: file {
  349. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  350. // CHECK:STDOUT: .C = imports.%import_ref.1
  351. // CHECK:STDOUT: .I = imports.%import_ref.2
  352. // CHECK:STDOUT: }
  353. // CHECK:STDOUT: %default.import.loc2_6.1 = import <invalid>
  354. // CHECK:STDOUT: %default.import.loc2_6.2 = import <invalid>
  355. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  356. // CHECK:STDOUT: %C.ref: type = name_ref C, imports.%import_ref.1 [template = constants.%C]
  357. // CHECK:STDOUT: %I.ref: %I.type.1 = name_ref I, imports.%import_ref.2 [template = constants.%I]
  358. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11 [symbolic = constants.%T]
  359. // CHECK:STDOUT: %.loc11: type = ptr_type %T [symbolic = constants.%.4]
  360. // CHECK:STDOUT: %I.type.loc11: type = interface_type @I, @I(constants.%.4) [symbolic = constants.%I.type.3]
  361. // CHECK:STDOUT: %param: type = param runtime_param<invalid>
  362. // CHECK:STDOUT: %T.loc11: type = bind_symbolic_name T, 0, %param [symbolic = constants.%T]
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: generic interface @I(constants.%T: type) {
  367. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  368. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt.1)]
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: !definition:
  371. // CHECK:STDOUT: %I.type: type = interface_type @I, @I(%T) [symbolic = %I.type (constants.%I.type.2)]
  372. // CHECK:STDOUT: %Self: %I.type.2 = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self.2)]
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: interface {
  375. // CHECK:STDOUT: !members:
  376. // CHECK:STDOUT: .Self = imports.%import_ref.3
  377. // CHECK:STDOUT: witness = ()
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: generic impl @impl.1(constants.%T: type) {
  382. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  383. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt.1)]
  384. // CHECK:STDOUT: %I.type: type = interface_type @I, @I(%T) [symbolic = %I.type (constants.%I.type.2)]
  385. // CHECK:STDOUT:
  386. // CHECK:STDOUT: impl: imports.%import_ref.5 as imports.%import_ref.6;
  387. // CHECK:STDOUT: }
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: generic impl @impl.2(constants.%T: type) {
  390. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  391. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt (constants.%T.patt.1)]
  392. // CHECK:STDOUT: %.1: type = ptr_type @impl.2.%T.1 (%T) [symbolic = %.1 (constants.%.4)]
  393. // CHECK:STDOUT: %I.type.1: type = interface_type @I, @I(%.1) [symbolic = %I.type.1 (constants.%I.type.3)]
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: !definition:
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: impl: imports.%import_ref.7 as imports.%import_ref.8 {
  398. // CHECK:STDOUT: !members:
  399. // CHECK:STDOUT: witness = imports.%import_ref.9
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: class @C {
  404. // CHECK:STDOUT: !members:
  405. // CHECK:STDOUT: .Self = imports.%import_ref.4
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: specific @I(constants.%T) {
  409. // CHECK:STDOUT: %T => constants.%T
  410. // CHECK:STDOUT: %T.patt => constants.%T
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: specific @I(@I.%T) {
  414. // CHECK:STDOUT: %T => constants.%T
  415. // CHECK:STDOUT: %T.patt => constants.%T
  416. // CHECK:STDOUT: }
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: specific @I(@impl.1.%T) {
  419. // CHECK:STDOUT: %T => constants.%T
  420. // CHECK:STDOUT: %T.patt => constants.%T
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: specific @impl.1(constants.%T) {
  424. // CHECK:STDOUT: %T => constants.%T
  425. // CHECK:STDOUT: %T.patt => constants.%T
  426. // CHECK:STDOUT: %I.type => constants.%I.type.2
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: specific @I(constants.%.4) {
  430. // CHECK:STDOUT: %T => constants.%.4
  431. // CHECK:STDOUT: %T.patt => constants.%.4
  432. // CHECK:STDOUT: }
  433. // CHECK:STDOUT:
  434. // CHECK:STDOUT: specific @I(@impl.2.%.1) {
  435. // CHECK:STDOUT: %T => constants.%.4
  436. // CHECK:STDOUT: %T.patt => constants.%.4
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: specific @impl.2(constants.%T) {
  440. // CHECK:STDOUT: %T.1 => constants.%T
  441. // CHECK:STDOUT: %T.patt => constants.%T
  442. // CHECK:STDOUT: %.1 => constants.%.4
  443. // CHECK:STDOUT: %I.type.1 => constants.%I.type.3
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT: