generic_vs_params.carbon 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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/class/no_prelude/generic_vs_params.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/no_prelude/generic_vs_params.carbon
  10. // --- params.carbon
  11. library "[[@TEST_NAME]]";
  12. class NotGenericNoParams {}
  13. class NotGenericButParams() {}
  14. class GenericAndParams(T:! type) {}
  15. class C(T:! type) {
  16. class GenericNoParams {}
  17. class GenericAndParams(U:! type) {}
  18. }
  19. class X {}
  20. var a: NotGenericNoParams = {};
  21. var b: NotGenericButParams() = {};
  22. var c: GenericAndParams(X) = {};
  23. var d: C(X).GenericNoParams = {};
  24. var e: C(X).GenericAndParams(X) = {};
  25. // --- fail_non_generic_implicit_params.carbon
  26. library "[[@TEST_NAME]]";
  27. // CHECK:STDERR: fail_non_generic_implicit_params.carbon:[[@LINE+4]]:9: error: parameters of generic types must be constant
  28. // CHECK:STDERR: class A[T: type]() {}
  29. // CHECK:STDERR: ^
  30. // CHECK:STDERR:
  31. class A[T: type]() {}
  32. // --- fail_non_generic_params.carbon
  33. library "[[@TEST_NAME]]";
  34. // CHECK:STDERR: fail_non_generic_params.carbon:[[@LINE+3]]:9: error: parameters of generic types must be constant
  35. // CHECK:STDERR: class A(T: type) {}
  36. // CHECK:STDERR: ^
  37. class A(T: type) {}
  38. // This is testing a use of the invalid type.
  39. fn F(T:! type) {
  40. A(T);
  41. }
  42. // CHECK:STDOUT: --- params.carbon
  43. // CHECK:STDOUT:
  44. // CHECK:STDOUT: constants {
  45. // CHECK:STDOUT: %NotGenericNoParams: type = class_type @NotGenericNoParams [template]
  46. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  47. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  48. // CHECK:STDOUT: %NotGenericButParams.type: type = generic_class_type @NotGenericButParams [template]
  49. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  50. // CHECK:STDOUT: %NotGenericButParams.1: %NotGenericButParams.type = struct_value () [template]
  51. // CHECK:STDOUT: %NotGenericButParams.2: type = class_type @NotGenericButParams [template]
  52. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  53. // CHECK:STDOUT: %GenericAndParams.type.1: type = generic_class_type @GenericAndParams.1 [template]
  54. // CHECK:STDOUT: %GenericAndParams.1: %GenericAndParams.type.1 = struct_value () [template]
  55. // CHECK:STDOUT: %GenericAndParams.2: type = class_type @GenericAndParams.1, @GenericAndParams.1(%T) [symbolic]
  56. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  57. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  58. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%T) [symbolic]
  59. // CHECK:STDOUT: %GenericNoParams.1: type = class_type @GenericNoParams [template]
  60. // CHECK:STDOUT: %GenericNoParams.2: type = class_type @GenericNoParams, @GenericNoParams(%T) [symbolic]
  61. // CHECK:STDOUT: %U: type = bind_symbolic_name U 1 [symbolic]
  62. // CHECK:STDOUT: %GenericAndParams.type.2: type = generic_class_type @GenericAndParams.2, @C(%T) [symbolic]
  63. // CHECK:STDOUT: %GenericAndParams.3: %GenericAndParams.type.2 = struct_value () [symbolic]
  64. // CHECK:STDOUT: %GenericAndParams.4: type = class_type @GenericAndParams.2, @GenericAndParams.2(%T, %U) [symbolic]
  65. // CHECK:STDOUT: %X: type = class_type @X [template]
  66. // CHECK:STDOUT: %.4: type = ptr_type %.1 [template]
  67. // CHECK:STDOUT: %struct.1: %NotGenericNoParams = struct_value () [template]
  68. // CHECK:STDOUT: %struct.2: %NotGenericButParams.2 = struct_value () [template]
  69. // CHECK:STDOUT: %GenericAndParams.5: type = class_type @GenericAndParams.1, @GenericAndParams.1(%X) [template]
  70. // CHECK:STDOUT: %struct.3: %GenericAndParams.5 = struct_value () [template]
  71. // CHECK:STDOUT: %C.3: type = class_type @C, @C(%X) [template]
  72. // CHECK:STDOUT: %GenericAndParams.type.3: type = generic_class_type @GenericAndParams.2, @C(%X) [template]
  73. // CHECK:STDOUT: %GenericAndParams.6: %GenericAndParams.type.3 = struct_value () [template]
  74. // CHECK:STDOUT: %struct.4: %GenericNoParams.1 = struct_value () [template]
  75. // CHECK:STDOUT: %GenericAndParams.7: type = class_type @GenericAndParams.2, @GenericAndParams.2(%X, %X) [template]
  76. // CHECK:STDOUT: %struct.5: %GenericAndParams.7 = struct_value () [template]
  77. // CHECK:STDOUT: }
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: file {
  80. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  81. // CHECK:STDOUT: .NotGenericNoParams = %NotGenericNoParams.decl
  82. // CHECK:STDOUT: .NotGenericButParams = %NotGenericButParams.decl
  83. // CHECK:STDOUT: .GenericAndParams = %GenericAndParams.decl
  84. // CHECK:STDOUT: .C = %C.decl
  85. // CHECK:STDOUT: .X = %X.decl
  86. // CHECK:STDOUT: .a = %a
  87. // CHECK:STDOUT: .b = %b
  88. // CHECK:STDOUT: .c = %c
  89. // CHECK:STDOUT: .d = %d
  90. // CHECK:STDOUT: .e = %e
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: %NotGenericNoParams.decl: type = class_decl @NotGenericNoParams [template = constants.%NotGenericNoParams] {} {}
  93. // CHECK:STDOUT: %NotGenericButParams.decl: %NotGenericButParams.type = class_decl @NotGenericButParams [template = constants.%NotGenericButParams.1] {} {}
  94. // CHECK:STDOUT: %GenericAndParams.decl: %GenericAndParams.type.1 = class_decl @GenericAndParams.1 [template = constants.%GenericAndParams.1] {
  95. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  96. // CHECK:STDOUT: } {
  97. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  98. // CHECK:STDOUT: %T.loc6: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] {
  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.loc8: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: %X.decl: type = class_decl @X [template = constants.%X] {} {}
  107. // CHECK:STDOUT: %NotGenericNoParams.ref: type = name_ref NotGenericNoParams, %NotGenericNoParams.decl [template = constants.%NotGenericNoParams]
  108. // CHECK:STDOUT: %a.var: ref %NotGenericNoParams = var a
  109. // CHECK:STDOUT: %a: ref %NotGenericNoParams = bind_name a, %a.var
  110. // CHECK:STDOUT: %NotGenericButParams.ref: %NotGenericButParams.type = name_ref NotGenericButParams, %NotGenericButParams.decl [template = constants.%NotGenericButParams.1]
  111. // CHECK:STDOUT: %NotGenericButParams: type = class_type @NotGenericButParams [template = constants.%NotGenericButParams.2]
  112. // CHECK:STDOUT: %b.var: ref %NotGenericButParams.2 = var b
  113. // CHECK:STDOUT: %b: ref %NotGenericButParams.2 = bind_name b, %b.var
  114. // CHECK:STDOUT: %GenericAndParams.ref.loc17: %GenericAndParams.type.1 = name_ref GenericAndParams, %GenericAndParams.decl [template = constants.%GenericAndParams.1]
  115. // CHECK:STDOUT: %X.ref.loc17: type = name_ref X, %X.decl [template = constants.%X]
  116. // CHECK:STDOUT: %GenericAndParams.loc17: type = class_type @GenericAndParams.1, @GenericAndParams.1(constants.%X) [template = constants.%GenericAndParams.5]
  117. // CHECK:STDOUT: %c.var: ref %GenericAndParams.5 = var c
  118. // CHECK:STDOUT: %c: ref %GenericAndParams.5 = bind_name c, %c.var
  119. // CHECK:STDOUT: %C.ref.loc18: %C.type = name_ref C, %C.decl [template = constants.%C.1]
  120. // CHECK:STDOUT: %X.ref.loc18: type = name_ref X, %X.decl [template = constants.%X]
  121. // CHECK:STDOUT: %C.loc18: type = class_type @C, @C(constants.%X) [template = constants.%C.3]
  122. // CHECK:STDOUT: %GenericNoParams.ref: type = name_ref GenericNoParams, @C.%GenericNoParams.decl [template = constants.%GenericNoParams.1]
  123. // CHECK:STDOUT: %d.var: ref %GenericNoParams.1 = var d
  124. // CHECK:STDOUT: %d: ref %GenericNoParams.1 = bind_name d, %d.var
  125. // CHECK:STDOUT: %C.ref.loc19: %C.type = name_ref C, %C.decl [template = constants.%C.1]
  126. // CHECK:STDOUT: %X.ref.loc19_10: type = name_ref X, %X.decl [template = constants.%X]
  127. // CHECK:STDOUT: %C.loc19: type = class_type @C, @C(constants.%X) [template = constants.%C.3]
  128. // CHECK:STDOUT: %.loc19: %GenericAndParams.type.3 = specific_constant @C.%GenericAndParams.decl, @C(constants.%X) [template = constants.%GenericAndParams.6]
  129. // CHECK:STDOUT: %GenericAndParams.ref.loc19: %GenericAndParams.type.3 = name_ref GenericAndParams, %.loc19 [template = constants.%GenericAndParams.6]
  130. // CHECK:STDOUT: %X.ref.loc19_30: type = name_ref X, %X.decl [template = constants.%X]
  131. // CHECK:STDOUT: %GenericAndParams.loc19: type = class_type @GenericAndParams.2, @GenericAndParams.2(constants.%X, constants.%X) [template = constants.%GenericAndParams.7]
  132. // CHECK:STDOUT: %e.var: ref %GenericAndParams.7 = var e
  133. // CHECK:STDOUT: %e: ref %GenericAndParams.7 = bind_name e, %e.var
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT:
  136. // CHECK:STDOUT: class @NotGenericNoParams {
  137. // CHECK:STDOUT: %.loc4: <witness> = complete_type_witness %.1 [template = constants.%.2]
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: !members:
  140. // CHECK:STDOUT: .Self = constants.%NotGenericNoParams
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT:
  143. // CHECK:STDOUT: class @NotGenericButParams {
  144. // CHECK:STDOUT: %.loc5: <witness> = complete_type_witness %.1 [template = constants.%.2]
  145. // CHECK:STDOUT:
  146. // CHECK:STDOUT: !members:
  147. // CHECK:STDOUT: .Self = constants.%NotGenericButParams.2
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: generic class @GenericAndParams.1(%T.loc6: type) {
  151. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  152. // CHECK:STDOUT:
  153. // CHECK:STDOUT: !definition:
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: class {
  156. // CHECK:STDOUT: %.loc6: <witness> = complete_type_witness %.1 [template = constants.%.2]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: !members:
  159. // CHECK:STDOUT: .Self = constants.%GenericAndParams.2
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT:
  163. // CHECK:STDOUT: generic class @C(%T.loc8: type) {
  164. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: !definition:
  167. // CHECK:STDOUT: %GenericAndParams.type: type = generic_class_type @GenericAndParams.2, @C(%T.1) [symbolic = %GenericAndParams.type (constants.%GenericAndParams.type.2)]
  168. // CHECK:STDOUT: %GenericAndParams: @C.%GenericAndParams.type (%GenericAndParams.type.2) = struct_value () [symbolic = %GenericAndParams (constants.%GenericAndParams.3)]
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: class {
  171. // CHECK:STDOUT: %GenericNoParams.decl: type = class_decl @GenericNoParams [template = constants.%GenericNoParams.1] {} {}
  172. // CHECK:STDOUT: %GenericAndParams.decl: @C.%GenericAndParams.type (%GenericAndParams.type.2) = class_decl @GenericAndParams.2 [symbolic = @C.%GenericAndParams (constants.%GenericAndParams.3)] {
  173. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U 1
  174. // CHECK:STDOUT: } {
  175. // CHECK:STDOUT: %U.param: type = param U, runtime_param<invalid>
  176. // CHECK:STDOUT: %U.loc10: type = bind_symbolic_name U 1, %U.param [symbolic = %U.1 (constants.%U)]
  177. // CHECK:STDOUT: }
  178. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.1 [template = constants.%.2]
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: !members:
  181. // CHECK:STDOUT: .Self = constants.%C.2
  182. // CHECK:STDOUT: .GenericNoParams = %GenericNoParams.decl
  183. // CHECK:STDOUT: .GenericAndParams = %GenericAndParams.decl
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: generic class @GenericNoParams(@C.%T.loc8: type) {
  188. // CHECK:STDOUT: !definition:
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: class {
  191. // CHECK:STDOUT: %.loc9: <witness> = complete_type_witness %.1 [template = constants.%.2]
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: !members:
  194. // CHECK:STDOUT: .Self = constants.%GenericNoParams.2
  195. // CHECK:STDOUT: }
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: generic class @GenericAndParams.2(@C.%T.loc8: type, %U.loc10: type) {
  199. // CHECK:STDOUT: %U.1: type = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)]
  200. // CHECK:STDOUT:
  201. // CHECK:STDOUT: !definition:
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: class {
  204. // CHECK:STDOUT: %.loc10: <witness> = complete_type_witness %.1 [template = constants.%.2]
  205. // CHECK:STDOUT:
  206. // CHECK:STDOUT: !members:
  207. // CHECK:STDOUT: .Self = constants.%GenericAndParams.4
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: }
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: class @X {
  212. // CHECK:STDOUT: %.loc13: <witness> = complete_type_witness %.1 [template = constants.%.2]
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: !members:
  215. // CHECK:STDOUT: .Self = constants.%X
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: fn @__global_init() {
  219. // CHECK:STDOUT: !entry:
  220. // CHECK:STDOUT: %.loc15_30.1: %.1 = struct_literal ()
  221. // CHECK:STDOUT: %.loc15_30.2: init %NotGenericNoParams = class_init (), file.%a.var [template = constants.%struct.1]
  222. // CHECK:STDOUT: %.loc15_31: init %NotGenericNoParams = converted %.loc15_30.1, %.loc15_30.2 [template = constants.%struct.1]
  223. // CHECK:STDOUT: assign file.%a.var, %.loc15_31
  224. // CHECK:STDOUT: %.loc16_33.1: %.1 = struct_literal ()
  225. // CHECK:STDOUT: %.loc16_33.2: init %NotGenericButParams.2 = class_init (), file.%b.var [template = constants.%struct.2]
  226. // CHECK:STDOUT: %.loc16_34: init %NotGenericButParams.2 = converted %.loc16_33.1, %.loc16_33.2 [template = constants.%struct.2]
  227. // CHECK:STDOUT: assign file.%b.var, %.loc16_34
  228. // CHECK:STDOUT: %.loc17_31.1: %.1 = struct_literal ()
  229. // CHECK:STDOUT: %.loc17_31.2: init %GenericAndParams.5 = class_init (), file.%c.var [template = constants.%struct.3]
  230. // CHECK:STDOUT: %.loc17_32: init %GenericAndParams.5 = converted %.loc17_31.1, %.loc17_31.2 [template = constants.%struct.3]
  231. // CHECK:STDOUT: assign file.%c.var, %.loc17_32
  232. // CHECK:STDOUT: %.loc18_32.1: %.1 = struct_literal ()
  233. // CHECK:STDOUT: %.loc18_32.2: init %GenericNoParams.1 = class_init (), file.%d.var [template = constants.%struct.4]
  234. // CHECK:STDOUT: %.loc18_33: init %GenericNoParams.1 = converted %.loc18_32.1, %.loc18_32.2 [template = constants.%struct.4]
  235. // CHECK:STDOUT: assign file.%d.var, %.loc18_33
  236. // CHECK:STDOUT: %.loc19_36.1: %.1 = struct_literal ()
  237. // CHECK:STDOUT: %.loc19_36.2: init %GenericAndParams.7 = class_init (), file.%e.var [template = constants.%struct.5]
  238. // CHECK:STDOUT: %.loc19_37: init %GenericAndParams.7 = converted %.loc19_36.1, %.loc19_36.2 [template = constants.%struct.5]
  239. // CHECK:STDOUT: assign file.%e.var, %.loc19_37
  240. // CHECK:STDOUT: return
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: specific @GenericAndParams.1(constants.%T) {
  244. // CHECK:STDOUT: %T.1 => constants.%T
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: specific @C(constants.%T) {
  248. // CHECK:STDOUT: %T.1 => constants.%T
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: specific @GenericNoParams(constants.%T) {}
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: specific @GenericAndParams.2(constants.%T, constants.%U) {
  254. // CHECK:STDOUT: %U.1 => constants.%U
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: specific @C(@C.%T.1) {
  258. // CHECK:STDOUT: %T.1 => constants.%T
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: specific @GenericAndParams.1(constants.%X) {
  262. // CHECK:STDOUT: %T.1 => constants.%X
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: !definition:
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: specific @C(constants.%X) {
  268. // CHECK:STDOUT: %T.1 => constants.%X
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: !definition:
  271. // CHECK:STDOUT: %GenericAndParams.type => constants.%GenericAndParams.type.3
  272. // CHECK:STDOUT: %GenericAndParams => constants.%GenericAndParams.6
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: specific @GenericAndParams.2(constants.%X, constants.%X) {
  276. // CHECK:STDOUT: %U.1 => constants.%X
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: !definition:
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: --- fail_non_generic_implicit_params.carbon
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: constants {
  284. // CHECK:STDOUT: %A.type: type = generic_class_type @A [template]
  285. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  286. // CHECK:STDOUT: %A.1: %A.type = struct_value () [template]
  287. // CHECK:STDOUT: %A.2: type = class_type @A [template]
  288. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  289. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: file {
  293. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  294. // CHECK:STDOUT: .A = %A.decl
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT: %A.decl: %A.type = class_decl @A [template = constants.%A.1] {
  297. // CHECK:STDOUT: %T.patt: type = binding_pattern T
  298. // CHECK:STDOUT: } {
  299. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  300. // CHECK:STDOUT: %T: type = bind_name T, %T.param
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT:
  304. // CHECK:STDOUT: class @A {
  305. // CHECK:STDOUT: %.loc8: <witness> = complete_type_witness %.2 [template = constants.%.3]
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: !members:
  308. // CHECK:STDOUT: .Self = constants.%A.2
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: --- fail_non_generic_params.carbon
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: constants {
  314. // CHECK:STDOUT: %A.type: type = generic_class_type @A [template]
  315. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  316. // CHECK:STDOUT: %A.1: %A.type = struct_value () [template]
  317. // CHECK:STDOUT: %A.2: type = class_type @A [template]
  318. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  319. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  320. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  321. // CHECK:STDOUT: %F.type: type = fn_type @F [template]
  322. // CHECK:STDOUT: %F: %F.type = struct_value () [template]
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: file {
  326. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  327. // CHECK:STDOUT: .A = %A.decl
  328. // CHECK:STDOUT: .F = %F.decl
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT: %A.decl: %A.type = class_decl @A [template = constants.%A.1] {
  331. // CHECK:STDOUT: %T.patt: type = binding_pattern T
  332. // CHECK:STDOUT: } {
  333. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  334. // CHECK:STDOUT: %T: type = bind_name T, %T.param
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [template = constants.%F] {
  337. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  338. // CHECK:STDOUT: } {
  339. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  340. // CHECK:STDOUT: %T.loc10: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: class @A {
  345. // CHECK:STDOUT: %.loc7: <witness> = complete_type_witness %.2 [template = constants.%.3]
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: !members:
  348. // CHECK:STDOUT: .Self = constants.%A.2
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: generic fn @F(%T.loc10: type) {
  352. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: !definition:
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: fn(%T.loc10: type) {
  357. // CHECK:STDOUT: !entry:
  358. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [template = constants.%A.1]
  359. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc10 [symbolic = %T.1 (constants.%T)]
  360. // CHECK:STDOUT: %A: type = class_type @A [template = constants.%A.2]
  361. // CHECK:STDOUT: return
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: specific @F(constants.%T) {
  366. // CHECK:STDOUT: %T.1 => constants.%T
  367. // CHECK:STDOUT: }
  368. // CHECK:STDOUT: