redeclare.carbon 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  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/generic/redeclare.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/redeclare.carbon
  10. // --- valid.carbon
  11. library "[[@TEST_NAME]]";
  12. class Generic(T:! type);
  13. class Generic(T:! type) {
  14. }
  15. // --- fail_mismatch_param_list.carbon
  16. library "[[@TEST_NAME]]";
  17. class A;
  18. // CHECK:STDERR: fail_mismatch_param_list.carbon:[[@LINE+7]]:1: error: redeclaration differs because of parameter list
  19. // CHECK:STDERR: class A(T:! type) {}
  20. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~
  21. // CHECK:STDERR: fail_mismatch_param_list.carbon:[[@LINE-4]]:1: note: previously declared without parameter list
  22. // CHECK:STDERR: class A;
  23. // CHECK:STDERR: ^~~~~~~~
  24. // CHECK:STDERR:
  25. class A(T:! type) {}
  26. // --- fail_mismatch_implicit_param_list.carbon
  27. library "[[@TEST_NAME]]";
  28. class B(N:! i32);
  29. // CHECK:STDERR: fail_mismatch_implicit_param_list.carbon:[[@LINE+7]]:1: error: redeclaration differs because of implicit parameter list
  30. // CHECK:STDERR: class B[T:! type](N:! T) {}
  31. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
  32. // CHECK:STDERR: fail_mismatch_implicit_param_list.carbon:[[@LINE-4]]:1: note: previously declared without implicit parameter list
  33. // CHECK:STDERR: class B(N:! i32);
  34. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~
  35. // CHECK:STDERR:
  36. class B[T:! type](N:! T) {}
  37. // --- fail_mismatch_param_count.carbon
  38. library "[[@TEST_NAME]]";
  39. class C(T:! type);
  40. // CHECK:STDERR: fail_mismatch_param_count.carbon:[[@LINE+7]]:1: error: redeclaration differs because of parameter count of 2
  41. // CHECK:STDERR: class C(T:! type, U:! i32) {}
  42. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  43. // CHECK:STDERR: fail_mismatch_param_count.carbon:[[@LINE-4]]:1: note: previously declared with parameter count of 1
  44. // CHECK:STDERR: class C(T:! type);
  45. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~
  46. // CHECK:STDERR:
  47. class C(T:! type, U:! i32) {}
  48. // --- fail_mismatch_param_type.carbon
  49. library "[[@TEST_NAME]]";
  50. class D(T:! type);
  51. // CHECK:STDERR: fail_mismatch_param_type.carbon:[[@LINE+7]]:9: error: redeclaration differs at parameter 1
  52. // CHECK:STDERR: class D(T:! i32) {}
  53. // CHECK:STDERR: ^
  54. // CHECK:STDERR: fail_mismatch_param_type.carbon:[[@LINE-4]]:9: note: previous declaration's corresponding parameter here
  55. // CHECK:STDERR: class D(T:! type);
  56. // CHECK:STDERR: ^
  57. // CHECK:STDERR:
  58. class D(T:! i32) {}
  59. // --- fail_mismatch_param_name.carbon
  60. library "[[@TEST_NAME]]";
  61. class E(T:! type);
  62. // CHECK:STDERR: fail_mismatch_param_name.carbon:[[@LINE+6]]:9: error: redeclaration differs at parameter 1
  63. // CHECK:STDERR: class E(U:! type) {}
  64. // CHECK:STDERR: ^
  65. // CHECK:STDERR: fail_mismatch_param_name.carbon:[[@LINE-4]]:9: note: previous declaration's corresponding parameter here
  66. // CHECK:STDERR: class E(T:! type);
  67. // CHECK:STDERR: ^
  68. class E(U:! type) {}
  69. // CHECK:STDOUT: --- valid.carbon
  70. // CHECK:STDOUT:
  71. // CHECK:STDOUT: constants {
  72. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  73. // CHECK:STDOUT: %Generic.type: type = generic_class_type @Generic [template]
  74. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  75. // CHECK:STDOUT: %Generic.1: %Generic.type = struct_value () [template]
  76. // CHECK:STDOUT: %Generic.2: type = class_type @Generic, @Generic(%T) [symbolic]
  77. // CHECK:STDOUT: %.2: type = struct_type {} [template]
  78. // CHECK:STDOUT: %.3: <witness> = complete_type_witness %.2 [template]
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT:
  81. // CHECK:STDOUT: imports {
  82. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  83. // CHECK:STDOUT: import Core//prelude
  84. // CHECK:STDOUT: import Core//prelude/operators
  85. // CHECK:STDOUT: import Core//prelude/types
  86. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  87. // CHECK:STDOUT: import Core//prelude/operators/as
  88. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  89. // CHECK:STDOUT: import Core//prelude/operators/comparison
  90. // CHECK:STDOUT: import Core//prelude/types/bool
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: file {
  95. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  96. // CHECK:STDOUT: .Core = imports.%Core
  97. // CHECK:STDOUT: .Generic = %Generic.decl.loc4
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT: %Core.import = import Core
  100. // CHECK:STDOUT: %Generic.decl.loc4: %Generic.type = class_decl @Generic [template = constants.%Generic.1] {
  101. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  102. // CHECK:STDOUT: } {
  103. // CHECK:STDOUT: %T.param.loc4: type = param T, runtime_param<invalid>
  104. // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T 0, %T.param.loc4 [symbolic = %T.1 (constants.%T)]
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT: %Generic.decl.loc6: %Generic.type = class_decl @Generic [template = constants.%Generic.1] {
  107. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  108. // CHECK:STDOUT: } {
  109. // CHECK:STDOUT: %T.param.loc6: type = param T, runtime_param<invalid>
  110. // CHECK:STDOUT: %T.loc6: type = bind_symbolic_name T 0, %T.param.loc6 [symbolic = constants.%T]
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: generic class @Generic(%T.loc4: type) {
  115. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  116. // CHECK:STDOUT:
  117. // CHECK:STDOUT: !definition:
  118. // CHECK:STDOUT:
  119. // CHECK:STDOUT: class {
  120. // CHECK:STDOUT: %.loc7: <witness> = complete_type_witness %.2 [template = constants.%.3]
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: !members:
  123. // CHECK:STDOUT: .Self = constants.%Generic.2
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: specific @Generic(constants.%T) {
  128. // CHECK:STDOUT: %T.1 => constants.%T
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: --- fail_mismatch_param_list.carbon
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: constants {
  134. // CHECK:STDOUT: %A: type = class_type @A [template]
  135. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  136. // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template]
  137. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  138. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  139. // CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T) [symbolic]
  140. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  141. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: imports {
  145. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  146. // CHECK:STDOUT: import Core//prelude
  147. // CHECK:STDOUT: import Core//prelude/operators
  148. // CHECK:STDOUT: import Core//prelude/types
  149. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  150. // CHECK:STDOUT: import Core//prelude/operators/as
  151. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  152. // CHECK:STDOUT: import Core//prelude/operators/comparison
  153. // CHECK:STDOUT: import Core//prelude/types/bool
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: file {
  158. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  159. // CHECK:STDOUT: .Core = imports.%Core
  160. // CHECK:STDOUT: .A = %A.decl
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: %Core.import = import Core
  163. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  164. // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
  165. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  166. // CHECK:STDOUT: } {
  167. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  168. // CHECK:STDOUT: %T.loc12: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT: }
  171. // CHECK:STDOUT:
  172. // CHECK:STDOUT: class @A;
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: generic class @.1(%T.loc12: type) {
  175. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: !definition:
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: class {
  180. // CHECK:STDOUT: %.loc12: <witness> = complete_type_witness %.4 [template = constants.%.5]
  181. // CHECK:STDOUT:
  182. // CHECK:STDOUT: !members:
  183. // CHECK:STDOUT: .Self = constants.%.3
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: specific @.1(constants.%T) {
  188. // CHECK:STDOUT: %T.1 => constants.%T
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: --- fail_mismatch_implicit_param_list.carbon
  192. // CHECK:STDOUT:
  193. // CHECK:STDOUT: constants {
  194. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  195. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  196. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  197. // CHECK:STDOUT: %N.1: i32 = bind_symbolic_name N 0 [symbolic]
  198. // CHECK:STDOUT: %B.type: type = generic_class_type @B [template]
  199. // CHECK:STDOUT: %B.1: %B.type = struct_value () [template]
  200. // CHECK:STDOUT: %B.2: type = class_type @B, @B(%N.1) [symbolic]
  201. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  202. // CHECK:STDOUT: %N.2: %T = bind_symbolic_name N 1 [symbolic]
  203. // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template]
  204. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  205. // CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T, %N.2) [symbolic]
  206. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  207. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: imports {
  211. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  212. // CHECK:STDOUT: .Int32 = %import_ref
  213. // CHECK:STDOUT: import Core//prelude
  214. // CHECK:STDOUT: import Core//prelude/operators
  215. // CHECK:STDOUT: import Core//prelude/types
  216. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  217. // CHECK:STDOUT: import Core//prelude/operators/as
  218. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  219. // CHECK:STDOUT: import Core//prelude/operators/comparison
  220. // CHECK:STDOUT: import Core//prelude/types/bool
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: file {
  226. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  227. // CHECK:STDOUT: .Core = imports.%Core
  228. // CHECK:STDOUT: .B = %B.decl
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT: %Core.import = import Core
  231. // CHECK:STDOUT: %B.decl: %B.type = class_decl @B [template = constants.%B.1] {
  232. // CHECK:STDOUT: %N.patt: i32 = symbolic_binding_pattern N 0
  233. // CHECK:STDOUT: } {
  234. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  235. // CHECK:STDOUT: %.loc4_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
  236. // CHECK:STDOUT: %.loc4_13.2: type = converted %int.make_type_32, %.loc4_13.1 [template = i32]
  237. // CHECK:STDOUT: %N.param: i32 = param N, runtime_param<invalid>
  238. // CHECK:STDOUT: %N.loc4: i32 = bind_symbolic_name N 0, %N.param [symbolic = %N.1 (constants.%N.1)]
  239. // CHECK:STDOUT: }
  240. // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
  241. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  242. // CHECK:STDOUT: %N.patt: @.1.%T.1 (%T) = symbolic_binding_pattern N 1
  243. // CHECK:STDOUT: } {
  244. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  245. // CHECK:STDOUT: %T.loc12: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  246. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T)]
  247. // CHECK:STDOUT: %N.param: @.1.%T.1 (%T) = param N, runtime_param<invalid>
  248. // CHECK:STDOUT: %N.loc12: @.1.%T.1 (%T) = bind_symbolic_name N 1, %N.param [symbolic = %N.1 (constants.%N.2)]
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT: }
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: generic class @B(%N.loc4: i32) {
  253. // CHECK:STDOUT: %N.1: i32 = bind_symbolic_name N 0 [symbolic = %N.1 (constants.%N.1)]
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: class;
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: generic class @.1(%T.loc12: type, %N.loc12: @.1.%T.1 (%T)) {
  259. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  260. // CHECK:STDOUT: %N.1: %T = bind_symbolic_name N 1 [symbolic = %N.1 (constants.%N.2)]
  261. // CHECK:STDOUT:
  262. // CHECK:STDOUT: !definition:
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: class {
  265. // CHECK:STDOUT: %.loc12: <witness> = complete_type_witness %.4 [template = constants.%.5]
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: !members:
  268. // CHECK:STDOUT: .Self = constants.%.3
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: specific @B(constants.%N.1) {
  275. // CHECK:STDOUT: %N.1 => constants.%N.1
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: specific @.1(constants.%T, constants.%N.2) {
  279. // CHECK:STDOUT: %T.1 => constants.%T
  280. // CHECK:STDOUT: %N.1 => constants.%N.2
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: --- fail_mismatch_param_count.carbon
  284. // CHECK:STDOUT:
  285. // CHECK:STDOUT: constants {
  286. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  287. // CHECK:STDOUT: %C.type: type = generic_class_type @C [template]
  288. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  289. // CHECK:STDOUT: %C.1: %C.type = struct_value () [template]
  290. // CHECK:STDOUT: %C.2: type = class_type @C, @C(%T) [symbolic]
  291. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  292. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  293. // CHECK:STDOUT: %U: i32 = bind_symbolic_name U 1 [symbolic]
  294. // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template]
  295. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  296. // CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T, %U) [symbolic]
  297. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  298. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  299. // CHECK:STDOUT: }
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: imports {
  302. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  303. // CHECK:STDOUT: .Int32 = %import_ref
  304. // CHECK:STDOUT: import Core//prelude
  305. // CHECK:STDOUT: import Core//prelude/operators
  306. // CHECK:STDOUT: import Core//prelude/types
  307. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  308. // CHECK:STDOUT: import Core//prelude/operators/as
  309. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  310. // CHECK:STDOUT: import Core//prelude/operators/comparison
  311. // CHECK:STDOUT: import Core//prelude/types/bool
  312. // CHECK:STDOUT: }
  313. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: file {
  317. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  318. // CHECK:STDOUT: .Core = imports.%Core
  319. // CHECK:STDOUT: .C = %C.decl
  320. // CHECK:STDOUT: }
  321. // CHECK:STDOUT: %Core.import = import Core
  322. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [template = constants.%C.1] {
  323. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  324. // CHECK:STDOUT: } {
  325. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  326. // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  327. // CHECK:STDOUT: }
  328. // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
  329. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  330. // CHECK:STDOUT: %U.patt: i32 = symbolic_binding_pattern U 1
  331. // CHECK:STDOUT: } {
  332. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  333. // CHECK:STDOUT: %T.loc12: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  334. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  335. // CHECK:STDOUT: %.loc12_23.1: type = value_of_initializer %int.make_type_32 [template = i32]
  336. // CHECK:STDOUT: %.loc12_23.2: type = converted %int.make_type_32, %.loc12_23.1 [template = i32]
  337. // CHECK:STDOUT: %U.param: i32 = param U, runtime_param<invalid>
  338. // CHECK:STDOUT: %U.loc12: i32 = bind_symbolic_name U 1, %U.param [symbolic = %U.1 (constants.%U)]
  339. // CHECK:STDOUT: }
  340. // CHECK:STDOUT: }
  341. // CHECK:STDOUT:
  342. // CHECK:STDOUT: generic class @C(%T.loc4: type) {
  343. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: class;
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: generic class @.1(%T.loc12: type, %U.loc12: i32) {
  349. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  350. // CHECK:STDOUT: %U.1: i32 = bind_symbolic_name U 1 [symbolic = %U.1 (constants.%U)]
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: !definition:
  353. // CHECK:STDOUT:
  354. // CHECK:STDOUT: class {
  355. // CHECK:STDOUT: %.loc12_29: <witness> = complete_type_witness %.4 [template = constants.%.5]
  356. // CHECK:STDOUT:
  357. // CHECK:STDOUT: !members:
  358. // CHECK:STDOUT: .Self = constants.%.3
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: specific @C(constants.%T) {
  365. // CHECK:STDOUT: %T.1 => constants.%T
  366. // CHECK:STDOUT: }
  367. // CHECK:STDOUT:
  368. // CHECK:STDOUT: specific @.1(constants.%T, constants.%U) {
  369. // CHECK:STDOUT: %T.1 => constants.%T
  370. // CHECK:STDOUT: %U.1 => constants.%U
  371. // CHECK:STDOUT: }
  372. // CHECK:STDOUT:
  373. // CHECK:STDOUT: --- fail_mismatch_param_type.carbon
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: constants {
  376. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic]
  377. // CHECK:STDOUT: %D.type: type = generic_class_type @D [template]
  378. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  379. // CHECK:STDOUT: %D.1: %D.type = struct_value () [template]
  380. // CHECK:STDOUT: %D.2: type = class_type @D, @D(%T.1) [symbolic]
  381. // CHECK:STDOUT: %Int32.type: type = fn_type @Int32 [template]
  382. // CHECK:STDOUT: %Int32: %Int32.type = struct_value () [template]
  383. // CHECK:STDOUT: %T.2: i32 = bind_symbolic_name T 0 [symbolic]
  384. // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template]
  385. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  386. // CHECK:STDOUT: %.3: type = class_type @.1, @.1(%T.2) [symbolic]
  387. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  388. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  389. // CHECK:STDOUT: }
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: imports {
  392. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  393. // CHECK:STDOUT: .Int32 = %import_ref
  394. // CHECK:STDOUT: import Core//prelude
  395. // CHECK:STDOUT: import Core//prelude/operators
  396. // CHECK:STDOUT: import Core//prelude/types
  397. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  398. // CHECK:STDOUT: import Core//prelude/operators/as
  399. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  400. // CHECK:STDOUT: import Core//prelude/operators/comparison
  401. // CHECK:STDOUT: import Core//prelude/types/bool
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT: %import_ref: %Int32.type = import_ref Core//prelude/types, inst+4, loaded [template = constants.%Int32]
  404. // CHECK:STDOUT: }
  405. // CHECK:STDOUT:
  406. // CHECK:STDOUT: file {
  407. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  408. // CHECK:STDOUT: .Core = imports.%Core
  409. // CHECK:STDOUT: .D = %D.decl
  410. // CHECK:STDOUT: }
  411. // CHECK:STDOUT: %Core.import = import Core
  412. // CHECK:STDOUT: %D.decl: %D.type = class_decl @D [template = constants.%D.1] {
  413. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  414. // CHECK:STDOUT: } {
  415. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  416. // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T.1)]
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
  419. // CHECK:STDOUT: %T.patt: i32 = symbolic_binding_pattern T 0
  420. // CHECK:STDOUT: } {
  421. // CHECK:STDOUT: %int.make_type_32: init type = call constants.%Int32() [template = i32]
  422. // CHECK:STDOUT: %.loc12_13.1: type = value_of_initializer %int.make_type_32 [template = i32]
  423. // CHECK:STDOUT: %.loc12_13.2: type = converted %int.make_type_32, %.loc12_13.1 [template = i32]
  424. // CHECK:STDOUT: %T.param: i32 = param T, runtime_param<invalid>
  425. // CHECK:STDOUT: %T.loc12: i32 = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T.2)]
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT: }
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: generic class @D(%T.loc4: type) {
  430. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.1)]
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: class;
  433. // CHECK:STDOUT: }
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: generic class @.1(%T.loc12: i32) {
  436. // CHECK:STDOUT: %T.1: i32 = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T.2)]
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: !definition:
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: class {
  441. // CHECK:STDOUT: %.loc12_19: <witness> = complete_type_witness %.4 [template = constants.%.5]
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: !members:
  444. // CHECK:STDOUT: .Self = constants.%.3
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT: }
  447. // CHECK:STDOUT:
  448. // CHECK:STDOUT: fn @Int32() -> type = "int.make_type_32";
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: specific @D(constants.%T.1) {
  451. // CHECK:STDOUT: %T.1 => constants.%T.1
  452. // CHECK:STDOUT: }
  453. // CHECK:STDOUT:
  454. // CHECK:STDOUT: specific @.1(constants.%T.2) {
  455. // CHECK:STDOUT: %T.1 => constants.%T.2
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: --- fail_mismatch_param_name.carbon
  459. // CHECK:STDOUT:
  460. // CHECK:STDOUT: constants {
  461. // CHECK:STDOUT: %T: type = bind_symbolic_name T 0 [symbolic]
  462. // CHECK:STDOUT: %E.type: type = generic_class_type @E [template]
  463. // CHECK:STDOUT: %.1: type = tuple_type () [template]
  464. // CHECK:STDOUT: %E.1: %E.type = struct_value () [template]
  465. // CHECK:STDOUT: %E.2: type = class_type @E, @E(%T) [symbolic]
  466. // CHECK:STDOUT: %U: type = bind_symbolic_name U 0 [symbolic]
  467. // CHECK:STDOUT: %.type: type = generic_class_type @.1 [template]
  468. // CHECK:STDOUT: %.2: %.type = struct_value () [template]
  469. // CHECK:STDOUT: %.3: type = class_type @.1, @.1(%U) [symbolic]
  470. // CHECK:STDOUT: %.4: type = struct_type {} [template]
  471. // CHECK:STDOUT: %.5: <witness> = complete_type_witness %.4 [template]
  472. // CHECK:STDOUT: }
  473. // CHECK:STDOUT:
  474. // CHECK:STDOUT: imports {
  475. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  476. // CHECK:STDOUT: import Core//prelude
  477. // CHECK:STDOUT: import Core//prelude/operators
  478. // CHECK:STDOUT: import Core//prelude/types
  479. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  480. // CHECK:STDOUT: import Core//prelude/operators/as
  481. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  482. // CHECK:STDOUT: import Core//prelude/operators/comparison
  483. // CHECK:STDOUT: import Core//prelude/types/bool
  484. // CHECK:STDOUT: }
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: file {
  488. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  489. // CHECK:STDOUT: .Core = imports.%Core
  490. // CHECK:STDOUT: .E = %E.decl
  491. // CHECK:STDOUT: }
  492. // CHECK:STDOUT: %Core.import = import Core
  493. // CHECK:STDOUT: %E.decl: %E.type = class_decl @E [template = constants.%E.1] {
  494. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T 0
  495. // CHECK:STDOUT: } {
  496. // CHECK:STDOUT: %T.param: type = param T, runtime_param<invalid>
  497. // CHECK:STDOUT: %T.loc4: type = bind_symbolic_name T 0, %T.param [symbolic = %T.1 (constants.%T)]
  498. // CHECK:STDOUT: }
  499. // CHECK:STDOUT: %.decl: %.type = class_decl @.1 [template = constants.%.2] {
  500. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U 0
  501. // CHECK:STDOUT: } {
  502. // CHECK:STDOUT: %U.param: type = param U, runtime_param<invalid>
  503. // CHECK:STDOUT: %U.loc11: type = bind_symbolic_name U 0, %U.param [symbolic = %U.1 (constants.%U)]
  504. // CHECK:STDOUT: }
  505. // CHECK:STDOUT: }
  506. // CHECK:STDOUT:
  507. // CHECK:STDOUT: generic class @E(%T.loc4: type) {
  508. // CHECK:STDOUT: %T.1: type = bind_symbolic_name T 0 [symbolic = %T.1 (constants.%T)]
  509. // CHECK:STDOUT:
  510. // CHECK:STDOUT: class;
  511. // CHECK:STDOUT: }
  512. // CHECK:STDOUT:
  513. // CHECK:STDOUT: generic class @.1(%U.loc11: type) {
  514. // CHECK:STDOUT: %U.1: type = bind_symbolic_name U 0 [symbolic = %U.1 (constants.%U)]
  515. // CHECK:STDOUT:
  516. // CHECK:STDOUT: !definition:
  517. // CHECK:STDOUT:
  518. // CHECK:STDOUT: class {
  519. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.4 [template = constants.%.5]
  520. // CHECK:STDOUT:
  521. // CHECK:STDOUT: !members:
  522. // CHECK:STDOUT: .Self = constants.%.3
  523. // CHECK:STDOUT: }
  524. // CHECK:STDOUT: }
  525. // CHECK:STDOUT:
  526. // CHECK:STDOUT: specific @E(constants.%T) {
  527. // CHECK:STDOUT: %T.1 => constants.%T
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: specific @.1(constants.%U) {
  531. // CHECK:STDOUT: %U.1 => constants.%U
  532. // CHECK:STDOUT: }
  533. // CHECK:STDOUT: