generic_vs_params.carbon 24 KB

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