generic_vs_params.carbon 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  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 [GenericParamMustBeConstant]
  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+4]]:9: error: parameters of generic types must be constant [GenericParamMustBeConstant]
  35. // CHECK:STDERR: class A(T: type) {}
  36. // CHECK:STDERR: ^~~~~~~
  37. // CHECK:STDERR:
  38. class A(T: type) {}
  39. // This is testing a use of the invalid type.
  40. fn F(T:! type) {
  41. A(T);
  42. }
  43. // --- fail_implicit_params_only_empty.carbon
  44. library "[[@TEST_NAME]]";
  45. // CHECK:STDERR: fail_implicit_params_only_empty.carbon:[[@LINE+4]]:10: error: expected explicit parameters after implicit parameters [GenericMissingExplicitParameters]
  46. // CHECK:STDERR: class Foo[];
  47. // CHECK:STDERR: ^~
  48. // CHECK:STDERR:
  49. class Foo[];
  50. // --- fail_implicit_params_only.carbon
  51. library "[[@TEST_NAME]]";
  52. // CHECK:STDERR: fail_implicit_params_only.carbon:[[@LINE+4]]:10: error: expected explicit parameters after implicit parameters [GenericMissingExplicitParameters]
  53. // CHECK:STDERR: class Foo[T:! type];
  54. // CHECK:STDERR: ^~~~~~~~~~
  55. // CHECK:STDERR:
  56. class Foo[T:! type];
  57. // CHECK:STDOUT: --- params.carbon
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: constants {
  60. // CHECK:STDOUT: %NotGenericNoParams: type = class_type @NotGenericNoParams [concrete]
  61. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  62. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  63. // CHECK:STDOUT: %NotGenericButParams.type: type = generic_class_type @NotGenericButParams [concrete]
  64. // CHECK:STDOUT: %NotGenericButParams.generic: %NotGenericButParams.type = struct_value () [concrete]
  65. // CHECK:STDOUT: %NotGenericButParams: type = class_type @NotGenericButParams [concrete]
  66. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  67. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  68. // CHECK:STDOUT: %GenericAndParams.type.c8d: type = generic_class_type @GenericAndParams.1 [concrete]
  69. // CHECK:STDOUT: %GenericAndParams.generic.1e4: %GenericAndParams.type.c8d = struct_value () [concrete]
  70. // CHECK:STDOUT: %GenericAndParams.2ce: type = class_type @GenericAndParams.1, @GenericAndParams.1(%T) [symbolic]
  71. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  72. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  73. // CHECK:STDOUT: %C.f2e: type = class_type @C, @C(%T) [symbolic]
  74. // CHECK:STDOUT: %GenericNoParams.72f: type = class_type @GenericNoParams [concrete]
  75. // CHECK:STDOUT: %GenericNoParams.fbf: type = class_type @GenericNoParams, @GenericNoParams(%T) [symbolic]
  76. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 1 [symbolic]
  77. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 1 [symbolic]
  78. // CHECK:STDOUT: %GenericAndParams.type.3ce: type = generic_class_type @GenericAndParams.2, @C(%T) [symbolic]
  79. // CHECK:STDOUT: %GenericAndParams.generic.54a: %GenericAndParams.type.3ce = struct_value () [symbolic]
  80. // CHECK:STDOUT: %GenericAndParams.425: type = class_type @GenericAndParams.2, @GenericAndParams.2(%T, %U) [symbolic]
  81. // CHECK:STDOUT: %X: type = class_type @X [concrete]
  82. // CHECK:STDOUT: %NotGenericNoParams.val: %NotGenericNoParams = struct_value () [concrete]
  83. // CHECK:STDOUT: %NotGenericButParams.val: %NotGenericButParams = struct_value () [concrete]
  84. // CHECK:STDOUT: %GenericAndParams.2bb: type = class_type @GenericAndParams.1, @GenericAndParams.1(%X) [concrete]
  85. // CHECK:STDOUT: %GenericAndParams.val.0b2: %GenericAndParams.2bb = struct_value () [concrete]
  86. // CHECK:STDOUT: %C.fac: type = class_type @C, @C(%X) [concrete]
  87. // CHECK:STDOUT: %GenericAndParams.type.c20: type = generic_class_type @GenericAndParams.2, @C(%X) [concrete]
  88. // CHECK:STDOUT: %GenericAndParams.generic.a55: %GenericAndParams.type.c20 = struct_value () [concrete]
  89. // CHECK:STDOUT: %GenericNoParams.val: %GenericNoParams.72f = struct_value () [concrete]
  90. // CHECK:STDOUT: %GenericAndParams.91f: type = class_type @GenericAndParams.2, @GenericAndParams.2(%X, %X) [concrete]
  91. // CHECK:STDOUT: %GenericAndParams.val.99b: %GenericAndParams.91f = struct_value () [concrete]
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: file {
  95. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  96. // CHECK:STDOUT: .NotGenericNoParams = %NotGenericNoParams.decl
  97. // CHECK:STDOUT: .NotGenericButParams = %NotGenericButParams.decl
  98. // CHECK:STDOUT: .GenericAndParams = %GenericAndParams.decl
  99. // CHECK:STDOUT: .C = %C.decl
  100. // CHECK:STDOUT: .X = %X.decl
  101. // CHECK:STDOUT: .a = %a
  102. // CHECK:STDOUT: .b = %b
  103. // CHECK:STDOUT: .c = %c
  104. // CHECK:STDOUT: .d = %d
  105. // CHECK:STDOUT: .e = %e
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT: %NotGenericNoParams.decl: type = class_decl @NotGenericNoParams [concrete = constants.%NotGenericNoParams] {} {}
  108. // CHECK:STDOUT: %NotGenericButParams.decl: %NotGenericButParams.type = class_decl @NotGenericButParams [concrete = constants.%NotGenericButParams.generic] {} {}
  109. // CHECK:STDOUT: %GenericAndParams.decl: %GenericAndParams.type.c8d = class_decl @GenericAndParams.1 [concrete = constants.%GenericAndParams.generic.1e4] {
  110. // CHECK:STDOUT: %T.patt.loc6_24.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_24.2 (constants.%T.patt)]
  111. // CHECK:STDOUT: } {
  112. // CHECK:STDOUT: %T.loc6_24.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_24.2 (constants.%T)]
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [concrete = constants.%C.generic] {
  115. // CHECK:STDOUT: %T.patt.loc8_9.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_9.2 (constants.%T.patt)]
  116. // CHECK:STDOUT: } {
  117. // CHECK:STDOUT: %T.loc8_9.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_9.2 (constants.%T)]
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT: %X.decl: type = class_decl @X [concrete = constants.%X] {} {}
  120. // CHECK:STDOUT: name_binding_decl {
  121. // CHECK:STDOUT: %a.patt: %NotGenericNoParams = binding_pattern a
  122. // CHECK:STDOUT: %.loc15: %NotGenericNoParams = var_pattern %a.patt
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: %a.var: ref %NotGenericNoParams = var a
  125. // CHECK:STDOUT: %NotGenericNoParams.ref: type = name_ref NotGenericNoParams, %NotGenericNoParams.decl [concrete = constants.%NotGenericNoParams]
  126. // CHECK:STDOUT: %a: ref %NotGenericNoParams = bind_name a, %a.var
  127. // CHECK:STDOUT: name_binding_decl {
  128. // CHECK:STDOUT: %b.patt: %NotGenericButParams = binding_pattern b
  129. // CHECK:STDOUT: %.loc16_1: %NotGenericButParams = var_pattern %b.patt
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT: %b.var: ref %NotGenericButParams = var b
  132. // CHECK:STDOUT: %.loc16_28: type = splice_block %NotGenericButParams [concrete = constants.%NotGenericButParams] {
  133. // CHECK:STDOUT: %NotGenericButParams.ref: %NotGenericButParams.type = name_ref NotGenericButParams, %NotGenericButParams.decl [concrete = constants.%NotGenericButParams.generic]
  134. // CHECK:STDOUT: %NotGenericButParams: type = class_type @NotGenericButParams [concrete = constants.%NotGenericButParams]
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT: %b: ref %NotGenericButParams = bind_name b, %b.var
  137. // CHECK:STDOUT: name_binding_decl {
  138. // CHECK:STDOUT: %c.patt: %GenericAndParams.2bb = binding_pattern c
  139. // CHECK:STDOUT: %.loc17_1: %GenericAndParams.2bb = var_pattern %c.patt
  140. // CHECK:STDOUT: }
  141. // CHECK:STDOUT: %c.var: ref %GenericAndParams.2bb = var c
  142. // CHECK:STDOUT: %.loc17_26: type = splice_block %GenericAndParams.loc17 [concrete = constants.%GenericAndParams.2bb] {
  143. // CHECK:STDOUT: %GenericAndParams.ref.loc17: %GenericAndParams.type.c8d = name_ref GenericAndParams, %GenericAndParams.decl [concrete = constants.%GenericAndParams.generic.1e4]
  144. // CHECK:STDOUT: %X.ref.loc17: type = name_ref X, %X.decl [concrete = constants.%X]
  145. // CHECK:STDOUT: %GenericAndParams.loc17: type = class_type @GenericAndParams.1, @GenericAndParams.1(constants.%X) [concrete = constants.%GenericAndParams.2bb]
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %c: ref %GenericAndParams.2bb = bind_name c, %c.var
  148. // CHECK:STDOUT: name_binding_decl {
  149. // CHECK:STDOUT: %d.patt: %GenericNoParams.72f = binding_pattern d
  150. // CHECK:STDOUT: %.loc18_1: %GenericNoParams.72f = var_pattern %d.patt
  151. // CHECK:STDOUT: }
  152. // CHECK:STDOUT: %d.var: ref %GenericNoParams.72f = var d
  153. // CHECK:STDOUT: %.loc18_12: type = splice_block %GenericNoParams.ref [concrete = constants.%GenericNoParams.72f] {
  154. // CHECK:STDOUT: %C.ref.loc18: %C.type = name_ref C, %C.decl [concrete = constants.%C.generic]
  155. // CHECK:STDOUT: %X.ref.loc18: type = name_ref X, %X.decl [concrete = constants.%X]
  156. // CHECK:STDOUT: %C.loc18: type = class_type @C, @C(constants.%X) [concrete = constants.%C.fac]
  157. // CHECK:STDOUT: %GenericNoParams.ref: type = name_ref GenericNoParams, @C.%GenericNoParams.decl [concrete = constants.%GenericNoParams.72f]
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: %d: ref %GenericNoParams.72f = bind_name d, %d.var
  160. // CHECK:STDOUT: name_binding_decl {
  161. // CHECK:STDOUT: %e.patt: %GenericAndParams.91f = binding_pattern e
  162. // CHECK:STDOUT: %.loc19_1: %GenericAndParams.91f = var_pattern %e.patt
  163. // CHECK:STDOUT: }
  164. // CHECK:STDOUT: %e.var: ref %GenericAndParams.91f = var e
  165. // CHECK:STDOUT: %.loc19_31: type = splice_block %GenericAndParams.loc19 [concrete = constants.%GenericAndParams.91f] {
  166. // CHECK:STDOUT: %C.ref.loc19: %C.type = name_ref C, %C.decl [concrete = constants.%C.generic]
  167. // CHECK:STDOUT: %X.ref.loc19_10: type = name_ref X, %X.decl [concrete = constants.%X]
  168. // CHECK:STDOUT: %C.loc19: type = class_type @C, @C(constants.%X) [concrete = constants.%C.fac]
  169. // CHECK:STDOUT: %.loc19_12: %GenericAndParams.type.c20 = specific_constant @C.%GenericAndParams.decl, @C(constants.%X) [concrete = constants.%GenericAndParams.generic.a55]
  170. // CHECK:STDOUT: %GenericAndParams.ref.loc19: %GenericAndParams.type.c20 = name_ref GenericAndParams, %.loc19_12 [concrete = constants.%GenericAndParams.generic.a55]
  171. // CHECK:STDOUT: %X.ref.loc19_30: type = name_ref X, %X.decl [concrete = constants.%X]
  172. // CHECK:STDOUT: %GenericAndParams.loc19: type = class_type @GenericAndParams.2, @GenericAndParams.2(constants.%X, constants.%X) [concrete = constants.%GenericAndParams.91f]
  173. // CHECK:STDOUT: }
  174. // CHECK:STDOUT: %e: ref %GenericAndParams.91f = bind_name e, %e.var
  175. // CHECK:STDOUT: }
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: class @NotGenericNoParams {
  178. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  179. // CHECK:STDOUT: complete_type_witness = %complete_type
  180. // CHECK:STDOUT:
  181. // CHECK:STDOUT: !members:
  182. // CHECK:STDOUT: .Self = constants.%NotGenericNoParams
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: class @NotGenericButParams {
  186. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  187. // CHECK:STDOUT: complete_type_witness = %complete_type
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: !members:
  190. // CHECK:STDOUT: .Self = constants.%NotGenericButParams
  191. // CHECK:STDOUT: }
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: generic class @GenericAndParams.1(%T.loc6_24.1: type) {
  194. // CHECK:STDOUT: %T.loc6_24.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc6_24.2 (constants.%T)]
  195. // CHECK:STDOUT: %T.patt.loc6_24.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc6_24.2 (constants.%T.patt)]
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: !definition:
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: class {
  200. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  201. // CHECK:STDOUT: complete_type_witness = %complete_type
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: !members:
  204. // CHECK:STDOUT: .Self = constants.%GenericAndParams.2ce
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT: }
  207. // CHECK:STDOUT:
  208. // CHECK:STDOUT: generic class @C(%T.loc8_9.1: type) {
  209. // CHECK:STDOUT: %T.loc8_9.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_9.2 (constants.%T)]
  210. // CHECK:STDOUT: %T.patt.loc8_9.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_9.2 (constants.%T.patt)]
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: !definition:
  213. // CHECK:STDOUT: %GenericAndParams.type: type = generic_class_type @GenericAndParams.2, @C(%T.loc8_9.2) [symbolic = %GenericAndParams.type (constants.%GenericAndParams.type.3ce)]
  214. // CHECK:STDOUT: %GenericAndParams.generic: @C.%GenericAndParams.type (%GenericAndParams.type.3ce) = struct_value () [symbolic = %GenericAndParams.generic (constants.%GenericAndParams.generic.54a)]
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: class {
  217. // CHECK:STDOUT: %GenericNoParams.decl: type = class_decl @GenericNoParams [concrete = constants.%GenericNoParams.72f] {} {}
  218. // CHECK:STDOUT: %GenericAndParams.decl: @C.%GenericAndParams.type (%GenericAndParams.type.3ce) = class_decl @GenericAndParams.2 [symbolic = @C.%GenericAndParams.generic (constants.%GenericAndParams.generic.54a)] {
  219. // CHECK:STDOUT: %U.patt.loc10_26.1: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc10_26.2 (constants.%U.patt)]
  220. // CHECK:STDOUT: } {
  221. // CHECK:STDOUT: %U.loc10_26.1: type = bind_symbolic_name U, 1 [symbolic = %U.loc10_26.2 (constants.%U)]
  222. // CHECK:STDOUT: }
  223. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  224. // CHECK:STDOUT: complete_type_witness = %complete_type
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: !members:
  227. // CHECK:STDOUT: .Self = constants.%C.f2e
  228. // CHECK:STDOUT: .GenericNoParams = %GenericNoParams.decl
  229. // CHECK:STDOUT: .GenericAndParams = %GenericAndParams.decl
  230. // CHECK:STDOUT: }
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: generic class @GenericNoParams(@C.%T.loc8_9.1: type) {
  234. // CHECK:STDOUT: !definition:
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: class {
  237. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  238. // CHECK:STDOUT: complete_type_witness = %complete_type
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: !members:
  241. // CHECK:STDOUT: .Self = constants.%GenericNoParams.fbf
  242. // CHECK:STDOUT: }
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: generic class @GenericAndParams.2(@C.%T.loc8_9.1: type, %U.loc10_26.1: type) {
  246. // CHECK:STDOUT: %U.loc10_26.2: type = bind_symbolic_name U, 1 [symbolic = %U.loc10_26.2 (constants.%U)]
  247. // CHECK:STDOUT: %U.patt.loc10_26.2: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc10_26.2 (constants.%U.patt)]
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: !definition:
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: class {
  252. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  253. // CHECK:STDOUT: complete_type_witness = %complete_type
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: !members:
  256. // CHECK:STDOUT: .Self = constants.%GenericAndParams.425
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: class @X {
  261. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  262. // CHECK:STDOUT: complete_type_witness = %complete_type
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: !members:
  265. // CHECK:STDOUT: .Self = constants.%X
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: fn @__global_init() {
  269. // CHECK:STDOUT: !entry:
  270. // CHECK:STDOUT: %.loc15_30.1: %empty_struct_type = struct_literal ()
  271. // CHECK:STDOUT: %.loc15_30.2: init %NotGenericNoParams = class_init (), file.%a.var [concrete = constants.%NotGenericNoParams.val]
  272. // CHECK:STDOUT: %.loc15_1: init %NotGenericNoParams = converted %.loc15_30.1, %.loc15_30.2 [concrete = constants.%NotGenericNoParams.val]
  273. // CHECK:STDOUT: assign file.%a.var, %.loc15_1
  274. // CHECK:STDOUT: %.loc16_33.1: %empty_struct_type = struct_literal ()
  275. // CHECK:STDOUT: %.loc16_33.2: init %NotGenericButParams = class_init (), file.%b.var [concrete = constants.%NotGenericButParams.val]
  276. // CHECK:STDOUT: %.loc16_1: init %NotGenericButParams = converted %.loc16_33.1, %.loc16_33.2 [concrete = constants.%NotGenericButParams.val]
  277. // CHECK:STDOUT: assign file.%b.var, %.loc16_1
  278. // CHECK:STDOUT: %.loc17_31.1: %empty_struct_type = struct_literal ()
  279. // CHECK:STDOUT: %.loc17_31.2: init %GenericAndParams.2bb = class_init (), file.%c.var [concrete = constants.%GenericAndParams.val.0b2]
  280. // CHECK:STDOUT: %.loc17_1: init %GenericAndParams.2bb = converted %.loc17_31.1, %.loc17_31.2 [concrete = constants.%GenericAndParams.val.0b2]
  281. // CHECK:STDOUT: assign file.%c.var, %.loc17_1
  282. // CHECK:STDOUT: %.loc18_32.1: %empty_struct_type = struct_literal ()
  283. // CHECK:STDOUT: %.loc18_32.2: init %GenericNoParams.72f = class_init (), file.%d.var [concrete = constants.%GenericNoParams.val]
  284. // CHECK:STDOUT: %.loc18_1: init %GenericNoParams.72f = converted %.loc18_32.1, %.loc18_32.2 [concrete = constants.%GenericNoParams.val]
  285. // CHECK:STDOUT: assign file.%d.var, %.loc18_1
  286. // CHECK:STDOUT: %.loc19_36.1: %empty_struct_type = struct_literal ()
  287. // CHECK:STDOUT: %.loc19_36.2: init %GenericAndParams.91f = class_init (), file.%e.var [concrete = constants.%GenericAndParams.val.99b]
  288. // CHECK:STDOUT: %.loc19_1: init %GenericAndParams.91f = converted %.loc19_36.1, %.loc19_36.2 [concrete = constants.%GenericAndParams.val.99b]
  289. // CHECK:STDOUT: assign file.%e.var, %.loc19_1
  290. // CHECK:STDOUT: return
  291. // CHECK:STDOUT: }
  292. // CHECK:STDOUT:
  293. // CHECK:STDOUT: specific @GenericAndParams.1(constants.%T) {
  294. // CHECK:STDOUT: %T.loc6_24.2 => constants.%T
  295. // CHECK:STDOUT: %T.patt.loc6_24.2 => constants.%T
  296. // CHECK:STDOUT: }
  297. // CHECK:STDOUT:
  298. // CHECK:STDOUT: specific @C(constants.%T) {
  299. // CHECK:STDOUT: %T.loc8_9.2 => constants.%T
  300. // CHECK:STDOUT: %T.patt.loc8_9.2 => constants.%T
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: specific @GenericNoParams(constants.%T) {}
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: specific @GenericAndParams.2(constants.%T, constants.%U) {
  306. // CHECK:STDOUT: %U.loc10_26.2 => constants.%U
  307. // CHECK:STDOUT: %U.patt.loc10_26.2 => constants.%U
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: specific @C(%T.loc8_9.2) {}
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: specific @GenericAndParams.1(constants.%X) {
  313. // CHECK:STDOUT: %T.loc6_24.2 => constants.%X
  314. // CHECK:STDOUT: %T.patt.loc6_24.2 => constants.%X
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: !definition:
  317. // CHECK:STDOUT: }
  318. // CHECK:STDOUT:
  319. // CHECK:STDOUT: specific @C(constants.%X) {
  320. // CHECK:STDOUT: %T.loc8_9.2 => constants.%X
  321. // CHECK:STDOUT: %T.patt.loc8_9.2 => constants.%X
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: !definition:
  324. // CHECK:STDOUT: %GenericAndParams.type => constants.%GenericAndParams.type.c20
  325. // CHECK:STDOUT: %GenericAndParams.generic => constants.%GenericAndParams.generic.a55
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: specific @GenericAndParams.2(constants.%X, constants.%X) {
  329. // CHECK:STDOUT: %U.loc10_26.2 => constants.%X
  330. // CHECK:STDOUT: %U.patt.loc10_26.2 => constants.%X
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: !definition:
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: --- fail_non_generic_implicit_params.carbon
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: constants {
  338. // CHECK:STDOUT: %A.type: type = generic_class_type @A [concrete]
  339. // CHECK:STDOUT: %A.generic: %A.type = struct_value () [concrete]
  340. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  341. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  342. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: file {
  346. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  347. // CHECK:STDOUT: .A = %A.decl
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT: %A.decl: %A.type = class_decl @A [concrete = constants.%A.generic] {} {}
  350. // CHECK:STDOUT: }
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: class @A {
  353. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  354. // CHECK:STDOUT: complete_type_witness = %complete_type
  355. // CHECK:STDOUT:
  356. // CHECK:STDOUT: !members:
  357. // CHECK:STDOUT: .Self = constants.%A
  358. // CHECK:STDOUT: }
  359. // CHECK:STDOUT:
  360. // CHECK:STDOUT: --- fail_non_generic_params.carbon
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: constants {
  363. // CHECK:STDOUT: %A.type: type = generic_class_type @A [concrete]
  364. // CHECK:STDOUT: %A.generic: %A.type = struct_value () [concrete]
  365. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  366. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  367. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  368. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  369. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  370. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  371. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: file {
  375. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  376. // CHECK:STDOUT: .A = %A.decl
  377. // CHECK:STDOUT: .F = %F.decl
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT: %A.decl: %A.type = class_decl @A [concrete = constants.%A.generic] {} {}
  380. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  381. // CHECK:STDOUT: %T.patt.loc11_6.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)]
  382. // CHECK:STDOUT: } {
  383. // CHECK:STDOUT: %T.loc11_6.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_6.2 (constants.%T)]
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: class @A {
  388. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  389. // CHECK:STDOUT: complete_type_witness = %complete_type
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: !members:
  392. // CHECK:STDOUT: .Self = constants.%A
  393. // CHECK:STDOUT: }
  394. // CHECK:STDOUT:
  395. // CHECK:STDOUT: generic fn @F(%T.loc11_6.1: type) {
  396. // CHECK:STDOUT: %T.loc11_6.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc11_6.2 (constants.%T)]
  397. // CHECK:STDOUT: %T.patt.loc11_6.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_6.2 (constants.%T.patt)]
  398. // CHECK:STDOUT:
  399. // CHECK:STDOUT: !definition:
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: fn(%T.patt.loc11_6.1: type) {
  402. // CHECK:STDOUT: !entry:
  403. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [concrete = constants.%A.generic]
  404. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc11_6.1 [symbolic = %T.loc11_6.2 (constants.%T)]
  405. // CHECK:STDOUT: %A: type = class_type @A [concrete = constants.%A]
  406. // CHECK:STDOUT: return
  407. // CHECK:STDOUT: }
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: specific @F(constants.%T) {
  411. // CHECK:STDOUT: %T.loc11_6.2 => constants.%T
  412. // CHECK:STDOUT: %T.patt.loc11_6.2 => constants.%T
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: --- fail_implicit_params_only_empty.carbon
  416. // CHECK:STDOUT:
  417. // CHECK:STDOUT: constants {
  418. // CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [concrete]
  419. // CHECK:STDOUT: %Foo.generic: %Foo.type = struct_value () [concrete]
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: file {
  423. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  424. // CHECK:STDOUT: .Foo = %Foo.decl
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [concrete = constants.%Foo.generic] {} {}
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: class @Foo;
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: --- fail_implicit_params_only.carbon
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: constants {
  434. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  435. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  436. // CHECK:STDOUT: %Foo.type: type = generic_class_type @Foo [concrete]
  437. // CHECK:STDOUT: %Foo.generic: %Foo.type = struct_value () [concrete]
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: file {
  441. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  442. // CHECK:STDOUT: .Foo = %Foo.decl
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT: %Foo.decl: %Foo.type = class_decl @Foo [concrete = constants.%Foo.generic] {
  445. // CHECK:STDOUT: %T.patt.loc8_11.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_11.2 (constants.%T.patt)]
  446. // CHECK:STDOUT: } {
  447. // CHECK:STDOUT: %T.loc8_11.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_11.2 (constants.%T)]
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: generic class @Foo(%T.loc8_11.1: type) {
  452. // CHECK:STDOUT: %T.loc8_11.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_11.2 (constants.%T)]
  453. // CHECK:STDOUT: %T.patt.loc8_11.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc8_11.2 (constants.%T.patt)]
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: class;
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: specific @Foo(constants.%T) {
  459. // CHECK:STDOUT: %T.loc8_11.2 => constants.%T
  460. // CHECK:STDOUT: %T.patt.loc8_11.2 => constants.%T
  461. // CHECK:STDOUT: }
  462. // CHECK:STDOUT: