generic.carbon 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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 "generic";
  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 "fail_mismatched_args";
  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: Cannot implicitly convert from `Generic` to `Generic`.
  40. // CHECK:STDERR: F(T);
  41. // CHECK:STDERR: ^~
  42. // CHECK:STDERR: fail_mismatched_args.carbon:[[@LINE-6]]:1: Initializing parameter 1 of function 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: %WithAssocFn.type: type = generic_interface_type @WithAssocFn [template]
  59. // CHECK:STDOUT: %WithAssocFn: %WithAssocFn.type = struct_value () [template]
  60. // CHECK:STDOUT: %.4: type = interface_type @WithAssocFn, @WithAssocFn(%T.1) [symbolic]
  61. // CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 1 [symbolic]
  62. // CHECK:STDOUT: %F.type.1: type = fn_type @F.1, @WithAssocFn(%T.1) [symbolic]
  63. // CHECK:STDOUT: %F.1: %F.type.1 = struct_value () [symbolic]
  64. // CHECK:STDOUT: %.5: type = assoc_entity_type %.4, %F.type.1 [symbolic]
  65. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, @WithAssocFn.%F.decl [symbolic]
  66. // CHECK:STDOUT: %C: type = class_type @C [template]
  67. // CHECK:STDOUT: %.7: type = interface_type @Simple, @Simple(%C) [template]
  68. // CHECK:STDOUT: %.8: <witness> = interface_witness () [template]
  69. // CHECK:STDOUT: %.9: type = interface_type @WithAssocFn, @WithAssocFn(%C) [template]
  70. // CHECK:STDOUT: %F.type.2: type = fn_type @F.2 [template]
  71. // CHECK:STDOUT: %F.2: %F.type.2 = struct_value () [template]
  72. // CHECK:STDOUT: %F.type.3: type = fn_type @F.1, @WithAssocFn(%C) [template]
  73. // CHECK:STDOUT: %F.3: %F.type.3 = struct_value () [template]
  74. // CHECK:STDOUT: %.10: type = assoc_entity_type %.9, %F.type.3 [template]
  75. // CHECK:STDOUT: %.11: %.10 = assoc_entity element0, @WithAssocFn.%F.decl [template]
  76. // CHECK:STDOUT: %.12: <witness> = interface_witness (%F.2) [template]
  77. // CHECK:STDOUT: %.13: type = ptr_type %.3 [template]
  78. // CHECK:STDOUT: %struct: %X = struct_value () [template]
  79. // CHECK:STDOUT: %N: %T.1 = bind_symbolic_name N 1 [symbolic]
  80. // CHECK:STDOUT: %WithImplicitArgs.type: type = generic_interface_type @WithImplicitArgs [template]
  81. // CHECK:STDOUT: %WithImplicitArgs: %WithImplicitArgs.type = struct_value () [template]
  82. // CHECK:STDOUT: %T.2: %.7 = bind_symbolic_name T 0 [symbolic]
  83. // CHECK:STDOUT: %Receive.type: type = fn_type @Receive [template]
  84. // CHECK:STDOUT: %Receive: %Receive.type = struct_value () [template]
  85. // CHECK:STDOUT: %Pass.type: type = fn_type @Pass [template]
  86. // CHECK:STDOUT: %Pass: %Pass.type = struct_value () [template]
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: file {
  90. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  91. // CHECK:STDOUT: .Simple = %Simple.decl
  92. // CHECK:STDOUT: .X = %X.decl
  93. // CHECK:STDOUT: .WithAssocFn = %WithAssocFn.decl
  94. // CHECK:STDOUT: .C = %C.decl
  95. // CHECK:STDOUT: .WithImplicitArgs = %WithImplicitArgs.decl
  96. // CHECK:STDOUT: .Receive = %Receive.decl
  97. // CHECK:STDOUT: .Pass = %Pass.decl
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: %Simple.decl: %Simple.type = interface_decl @Simple [template = constants.%Simple] {
  100. // CHECK:STDOUT: %T.loc4_18.1: type = param T
  101. // CHECK:STDOUT: %T.loc4_18.2: type = bind_symbolic_name T 0, %T.loc4_18.1 [symbolic = @Simple.%T (constants.%T.1)]
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {}
  104. // CHECK:STDOUT: %WithAssocFn.decl: %WithAssocFn.type = interface_decl @WithAssocFn [template = constants.%WithAssocFn] {
  105. // CHECK:STDOUT: %T.loc8_23.1: type = param T
  106. // CHECK:STDOUT: %T.loc8_23.2: type = bind_symbolic_name T 0, %T.loc8_23.1 [symbolic = @WithAssocFn.%T (constants.%T.1)]
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  109. // CHECK:STDOUT: %WithImplicitArgs.decl: %WithImplicitArgs.type = interface_decl @WithImplicitArgs [template = constants.%WithImplicitArgs] {
  110. // CHECK:STDOUT: %T.loc22_28.1: type = param T
  111. // CHECK:STDOUT: %T.loc22_28.2: type = bind_symbolic_name T 0, %T.loc22_28.1 [symbolic = @WithImplicitArgs.%T (constants.%T.1)]
  112. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc22_28.2 [symbolic = @WithImplicitArgs.%T (constants.%T.1)]
  113. // CHECK:STDOUT: %N.loc22_38.1: @WithImplicitArgs.%T (%T.1) = param N
  114. // CHECK:STDOUT: %N.loc22_38.2: @WithImplicitArgs.%T (%T.1) = bind_symbolic_name N 1, %N.loc22_38.1 [symbolic = @WithImplicitArgs.%N (constants.%N)]
  115. // CHECK:STDOUT: }
  116. // CHECK:STDOUT: %Receive.decl: %Receive.type = fn_decl @Receive [template = constants.%Receive] {
  117. // CHECK:STDOUT: %Simple.ref.loc24: %Simple.type = name_ref Simple, %Simple.decl [template = constants.%Simple]
  118. // CHECK:STDOUT: %C.ref.loc24: type = name_ref C, %C.decl [template = constants.%C]
  119. // CHECK:STDOUT: %.loc24_22: init type = call %Simple.ref.loc24(%C.ref.loc24) [template = constants.%.7]
  120. // CHECK:STDOUT: %.loc24_24.1: type = value_of_initializer %.loc24_22 [template = constants.%.7]
  121. // CHECK:STDOUT: %.loc24_24.2: type = converted %.loc24_22, %.loc24_24.1 [template = constants.%.7]
  122. // CHECK:STDOUT: %T.loc24_12.1: %.7 = param T
  123. // CHECK:STDOUT: @Receive.%T.loc24: %.7 = bind_symbolic_name T 0, %T.loc24_12.1 [symbolic = @Receive.%T.1 (constants.%T.2)]
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: %Pass.decl: %Pass.type = fn_decl @Pass [template = constants.%Pass] {
  126. // CHECK:STDOUT: %Simple.ref.loc25: %Simple.type = name_ref Simple, %Simple.decl [template = constants.%Simple]
  127. // CHECK:STDOUT: %C.ref.loc25: type = name_ref C, %C.decl [template = constants.%C]
  128. // CHECK:STDOUT: %.loc25_19: init type = call %Simple.ref.loc25(%C.ref.loc25) [template = constants.%.7]
  129. // CHECK:STDOUT: %.loc25_21.1: type = value_of_initializer %.loc25_19 [template = constants.%.7]
  130. // CHECK:STDOUT: %.loc25_21.2: type = converted %.loc25_19, %.loc25_21.1 [template = constants.%.7]
  131. // CHECK:STDOUT: %T.loc25_9.1: %.7 = param T
  132. // CHECK:STDOUT: @Pass.%T.loc25: %.7 = bind_symbolic_name T 0, %T.loc25_9.1 [symbolic = @Pass.%T.1 (constants.%T.2)]
  133. // CHECK:STDOUT: }
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: generic interface @Simple(file.%T.loc4_18.2: type) {
  137. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)]
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: !definition:
  140. // CHECK:STDOUT: %.1: type = interface_type @Simple, @Simple(%T) [symbolic = %.1 (constants.%.2)]
  141. // CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)]
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: interface {
  144. // CHECK:STDOUT: %Self.1: @Simple.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.1)]
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: !members:
  147. // CHECK:STDOUT: .Self = %Self.1
  148. // CHECK:STDOUT: witness = ()
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: generic interface @WithAssocFn(file.%T.loc8_23.2: type) {
  153. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)]
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: !definition:
  156. // CHECK:STDOUT: %.1: type = interface_type @WithAssocFn, @WithAssocFn(%T) [symbolic = %.1 (constants.%.4)]
  157. // CHECK:STDOUT: %Self.2: %.4 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.2)]
  158. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @WithAssocFn(%T) [symbolic = %F.type (constants.%F.type.1)]
  159. // CHECK:STDOUT: %F: @WithAssocFn.%F.type (%F.type.1) = struct_value () [symbolic = %F (constants.%F.1)]
  160. // CHECK:STDOUT: %.2: type = assoc_entity_type @WithAssocFn.%.1 (%.4), @WithAssocFn.%F.type (%F.type.1) [symbolic = %.2 (constants.%.5)]
  161. // CHECK:STDOUT: %.3: @WithAssocFn.%.2 (%.5) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.6)]
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: interface {
  164. // CHECK:STDOUT: %Self.1: @WithAssocFn.%.1 (%.4) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self.2)]
  165. // CHECK:STDOUT: %F.decl: @WithAssocFn.%F.type (%F.type.1) = fn_decl @F.1 [symbolic = %F (constants.%F.1)] {
  166. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  167. // CHECK:STDOUT: %return.var: ref %X = var <return slot>
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: %.loc10: @WithAssocFn.%.2 (%.5) = assoc_entity element0, %F.decl [symbolic = %.3 (constants.%.6)]
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: !members:
  172. // CHECK:STDOUT: .Self = %Self.1
  173. // CHECK:STDOUT: .F = %.loc10
  174. // CHECK:STDOUT: witness = (%F.decl)
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT: }
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: generic interface @WithImplicitArgs(file.%T.loc22_28.2: type, file.%N.loc22_38.2: @WithImplicitArgs.%T (%T.1)) {
  179. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)]
  180. // CHECK:STDOUT: %N: %T.1 = bind_symbolic_name N 1 [symbolic = %N (constants.%N)]
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: interface;
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: impl @impl.1: %C as %.7 {
  186. // CHECK:STDOUT: %.1: <witness> = interface_witness () [template = constants.%.8]
  187. // CHECK:STDOUT:
  188. // CHECK:STDOUT: !members:
  189. // CHECK:STDOUT: witness = %.1
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: impl @impl.2: %C as %.9 {
  193. // CHECK:STDOUT: %F.decl: %F.type.2 = fn_decl @F.2 [template = constants.%F.2] {
  194. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [template = constants.%X]
  195. // CHECK:STDOUT: %return.var: ref %X = var <return slot>
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: %.1: <witness> = interface_witness (%F.decl) [template = constants.%.12]
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: !members:
  200. // CHECK:STDOUT: .F = %F.decl
  201. // CHECK:STDOUT: witness = %.1
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: class @X {
  205. // CHECK:STDOUT: !members:
  206. // CHECK:STDOUT: .Self = constants.%X
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: class @C {
  210. // CHECK:STDOUT: %.loc14_19.1: type = value_of_initializer %.loc14_17 [template = constants.%.7]
  211. // CHECK:STDOUT: %.loc14_19.2: type = converted %.loc14_17, %.loc14_19.1 [template = constants.%.7]
  212. // CHECK:STDOUT: impl_decl @impl.1 {
  213. // CHECK:STDOUT: %Simple.ref: %Simple.type = name_ref Simple, file.%Simple.decl [template = constants.%Simple]
  214. // CHECK:STDOUT: %C.ref.loc14: type = name_ref C, file.%C.decl [template = constants.%C]
  215. // CHECK:STDOUT: %.loc14_17: init type = call %Simple.ref(%C.ref.loc14) [template = constants.%.7]
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT: %.loc15_24.1: type = value_of_initializer %.loc15_22 [template = constants.%.9]
  218. // CHECK:STDOUT: %.loc15_24.2: type = converted %.loc15_22, %.loc15_24.1 [template = constants.%.9]
  219. // CHECK:STDOUT: impl_decl @impl.2 {
  220. // CHECK:STDOUT: %WithAssocFn.ref: %WithAssocFn.type = name_ref WithAssocFn, file.%WithAssocFn.decl [template = constants.%WithAssocFn]
  221. // CHECK:STDOUT: %C.ref.loc15: type = name_ref C, file.%C.decl [template = constants.%C]
  222. // CHECK:STDOUT: %.loc15_22: init type = call %WithAssocFn.ref(%C.ref.loc15) [template = constants.%.9]
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: !members:
  226. // CHECK:STDOUT: .Self = constants.%C
  227. // CHECK:STDOUT: }
  228. // CHECK:STDOUT:
  229. // CHECK:STDOUT: generic fn @F.1(file.%T.loc8_23.2: type, @WithAssocFn.%Self.1: @WithAssocFn.%.1 (%.4)) {
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: fn() -> %X;
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: fn @F.2() -> @impl.2.%return.var: %X {
  235. // CHECK:STDOUT: !entry:
  236. // CHECK:STDOUT: %.loc17_15.1: %.3 = struct_literal ()
  237. // CHECK:STDOUT: %.loc17_15.2: init %X = class_init (), @impl.2.%return.var [template = constants.%struct]
  238. // CHECK:STDOUT: %.loc17_16: init %X = converted %.loc17_15.1, %.loc17_15.2 [template = constants.%struct]
  239. // CHECK:STDOUT: return %.loc17_16 to @impl.2.%return.var
  240. // CHECK:STDOUT: }
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: generic fn @Receive(%T.loc24: %.7) {
  243. // CHECK:STDOUT: %T.1: %.7 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)]
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: fn(%T.loc24: %.7);
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: generic fn @Pass(%T.loc25: %.7) {
  249. // CHECK:STDOUT: %T.1: %.7 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)]
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: !definition:
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: fn(%T.loc25: %.7) {
  254. // CHECK:STDOUT: !entry:
  255. // CHECK:STDOUT: %Receive.ref: %Receive.type = name_ref Receive, file.%Receive.decl [template = constants.%Receive]
  256. // CHECK:STDOUT: %T.ref: %.7 = name_ref T, %T.loc25 [symbolic = %T.1 (constants.%T.2)]
  257. // CHECK:STDOUT: %Receive.call: init %.1 = call %Receive.ref(%T.ref)
  258. // CHECK:STDOUT: return
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT: }
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: specific @Simple(constants.%T.1) {
  263. // CHECK:STDOUT: %T => constants.%T.1
  264. // CHECK:STDOUT: }
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: specific @Simple(@Simple.%T) {
  267. // CHECK:STDOUT: %T => constants.%T.1
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: specific @WithAssocFn(constants.%T.1) {
  271. // CHECK:STDOUT: %T => constants.%T.1
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: specific @F.1(constants.%T.1, constants.%Self.2) {}
  275. // CHECK:STDOUT:
  276. // CHECK:STDOUT: specific @WithAssocFn(@WithAssocFn.%T) {
  277. // CHECK:STDOUT: %T => constants.%T.1
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: specific @Simple(constants.%C) {
  281. // CHECK:STDOUT: %T => constants.%C
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: !definition:
  284. // CHECK:STDOUT: %.1 => constants.%.7
  285. // CHECK:STDOUT: %Self.2 => constants.%Self.1
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: specific @WithAssocFn(constants.%C) {
  289. // CHECK:STDOUT: %T => constants.%C
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: !definition:
  292. // CHECK:STDOUT: %.1 => constants.%.9
  293. // CHECK:STDOUT: %Self.2 => constants.%Self.2
  294. // CHECK:STDOUT: %F.type => constants.%F.type.3
  295. // CHECK:STDOUT: %F => constants.%F.3
  296. // CHECK:STDOUT: %.2 => constants.%.10
  297. // CHECK:STDOUT: %.3 => constants.%.11
  298. // CHECK:STDOUT: }
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: specific @F.1(constants.%C, constants.%C) {}
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: specific @WithImplicitArgs(constants.%T.1, constants.%N) {
  303. // CHECK:STDOUT: %T => constants.%T.1
  304. // CHECK:STDOUT: %N => constants.%N
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: specific @Receive(constants.%T.2) {
  308. // CHECK:STDOUT: %T.1 => constants.%T.2
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: specific @Pass(constants.%T.2) {
  312. // CHECK:STDOUT: %T.1 => constants.%T.2
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: --- fail_mismatched_args.carbon
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: constants {
  318. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic]
  319. // CHECK:STDOUT: %Generic.type: type = generic_interface_type @Generic [template]
  320. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  321. // CHECK:STDOUT: %Generic: %Generic.type = struct_value () [template]
  322. // CHECK:STDOUT: %.2: type = interface_type @Generic, @Generic(%T.1) [symbolic]
  323. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 1 [symbolic]
  324. // CHECK:STDOUT: %A: type = class_type @A [template]
  325. // CHECK:STDOUT: %.3: type = struct_type {} [template]
  326. // CHECK:STDOUT: %B: type = class_type @B [template]
  327. // CHECK:STDOUT: %.4: type = interface_type @Generic, @Generic(%A) [template]
  328. // CHECK:STDOUT: %T.2: %.4 = bind_symbolic_name T 0 [symbolic]
  329. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  330. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  331. // CHECK:STDOUT: %.5: type = interface_type @Generic, @Generic(%B) [template]
  332. // CHECK:STDOUT: %T.3: %.5 = bind_symbolic_name T 0 [symbolic]
  333. // CHECK:STDOUT: %G.type: type = fn_type @G [template]
  334. // CHECK:STDOUT: %G: %G.type = struct_value () [template]
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: file {
  338. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  339. // CHECK:STDOUT: .Generic = %Generic.decl
  340. // CHECK:STDOUT: .A = %A.decl
  341. // CHECK:STDOUT: .B = %B.decl
  342. // CHECK:STDOUT: .F = %F.decl
  343. // CHECK:STDOUT: .G = %G.decl
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: %Generic.decl: %Generic.type = interface_decl @Generic [template = constants.%Generic] {
  346. // CHECK:STDOUT: %T.loc4_19.1: type = param T
  347. // CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T 0, %T.loc4_19.1 [symbolic = @Generic.%T (constants.%T.1)]
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {}
  350. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {}
  351. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  352. // CHECK:STDOUT: %Generic.ref.loc9: %Generic.type = name_ref Generic, %Generic.decl [template = constants.%Generic]
  353. // CHECK:STDOUT: %A.ref: type = name_ref A, %A.decl [template = constants.%A]
  354. // CHECK:STDOUT: %.loc9_17: init type = call %Generic.ref.loc9(%A.ref) [template = constants.%.4]
  355. // CHECK:STDOUT: %.loc9_19.1: type = value_of_initializer %.loc9_17 [template = constants.%.4]
  356. // CHECK:STDOUT: %.loc9_19.2: type = converted %.loc9_17, %.loc9_19.1 [template = constants.%.4]
  357. // CHECK:STDOUT: %T.loc9_6.1: %.4 = param T
  358. // CHECK:STDOUT: @F.%T.loc9: %.4 = bind_symbolic_name T 0, %T.loc9_6.1 [symbolic = @F.%T.1 (constants.%T.2)]
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [template = constants.%G] {
  361. // CHECK:STDOUT: %Generic.ref.loc10: %Generic.type = name_ref Generic, %Generic.decl [template = constants.%Generic]
  362. // CHECK:STDOUT: %B.ref: type = name_ref B, %B.decl [template = constants.%B]
  363. // CHECK:STDOUT: %.loc10_17: init type = call %Generic.ref.loc10(%B.ref) [template = constants.%.5]
  364. // CHECK:STDOUT: %.loc10_19.1: type = value_of_initializer %.loc10_17 [template = constants.%.5]
  365. // CHECK:STDOUT: %.loc10_19.2: type = converted %.loc10_17, %.loc10_19.1 [template = constants.%.5]
  366. // CHECK:STDOUT: %T.loc10_6.1: %.5 = param T
  367. // CHECK:STDOUT: @G.%T.loc10: %.5 = bind_symbolic_name T 0, %T.loc10_6.1 [symbolic = @G.%T.1 (constants.%T.3)]
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT: }
  370. // CHECK:STDOUT:
  371. // CHECK:STDOUT: generic interface @Generic(file.%T.loc4_19.2: type) {
  372. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic = %T (constants.%T.1)]
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: !definition:
  375. // CHECK:STDOUT: %.1: type = interface_type @Generic, @Generic(%T) [symbolic = %.1 (constants.%.2)]
  376. // CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)]
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: interface {
  379. // CHECK:STDOUT: %Self.1: @Generic.%.1 (%.2) = bind_symbolic_name Self 1 [symbolic = %Self.2 (constants.%Self)]
  380. // CHECK:STDOUT:
  381. // CHECK:STDOUT: !members:
  382. // CHECK:STDOUT: .Self = %Self.1
  383. // CHECK:STDOUT: witness = ()
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: class @A {
  388. // CHECK:STDOUT: !members:
  389. // CHECK:STDOUT: .Self = constants.%A
  390. // CHECK:STDOUT: }
  391. // CHECK:STDOUT:
  392. // CHECK:STDOUT: class @B {
  393. // CHECK:STDOUT: !members:
  394. // CHECK:STDOUT: .Self = constants.%B
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: generic fn @F(%T.loc9: %.4) {
  398. // CHECK:STDOUT: %T.1: %.4 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)]
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: fn(%T.loc9: %.4);
  401. // CHECK:STDOUT: }
  402. // CHECK:STDOUT:
  403. // CHECK:STDOUT: generic fn @G(%T.loc10: %.5) {
  404. // CHECK:STDOUT: %T.1: %.5 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.3)]
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: !definition:
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: fn(%T.loc10: %.5) {
  409. // CHECK:STDOUT: !entry:
  410. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [template = constants.%F]
  411. // CHECK:STDOUT: %T.ref: %.5 = name_ref T, %T.loc10 [symbolic = %T.1 (constants.%T.3)]
  412. // CHECK:STDOUT: %F.call: init %.1 = call %F.ref(<invalid>) [template = <error>]
  413. // CHECK:STDOUT: return
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT: }
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: specific @Generic(constants.%T.1) {
  418. // CHECK:STDOUT: %T => constants.%T.1
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: specific @Generic(@Generic.%T) {
  422. // CHECK:STDOUT: %T => constants.%T.1
  423. // CHECK:STDOUT: }
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: specific @Generic(constants.%A) {
  426. // CHECK:STDOUT: %T => constants.%A
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: specific @F(constants.%T.2) {
  430. // CHECK:STDOUT: %T.1 => constants.%T.2
  431. // CHECK:STDOUT: }
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: specific @Generic(constants.%B) {
  434. // CHECK:STDOUT: %T => constants.%B
  435. // CHECK:STDOUT: }
  436. // CHECK:STDOUT:
  437. // CHECK:STDOUT: specific @G(constants.%T.3) {
  438. // CHECK:STDOUT: %T.1 => constants.%T.3
  439. // CHECK:STDOUT: }
  440. // CHECK:STDOUT:
  441. // CHECK:STDOUT: specific @F(constants.%T.3) {
  442. // CHECK:STDOUT: %T.1 => constants.%T.3
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT: