import_generic.carbon 23 KB

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