generic.carbon 22 KB

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