import_generic.carbon 22 KB

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