generic_redeclaration.carbon 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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/impl/no_prelude/generic_redeclaration.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/generic_redeclaration.carbon
  10. // --- same_self_and_interface.carbon
  11. library "[[@TEST_NAME]]";
  12. interface Interface {}
  13. interface I {}
  14. interface J {}
  15. interface K {}
  16. interface L {}
  17. impl forall [T:! I] T as Interface;
  18. impl forall [T:! J] T as Interface;
  19. impl forall [T:! K] T as Interface;
  20. impl forall [T:! L] T as Interface;
  21. // These are two different impls, so this is not a redefinition, even though the
  22. // self type and constraint type are the same.
  23. impl forall [T:! I] T as Interface {}
  24. impl forall [T:! J] T as Interface {}
  25. impl forall [T:! K] T as Interface {}
  26. impl forall [T:! L] T as Interface {}
  27. // --- fail_same_self_and_interface_redefined.carbon
  28. library "[[@TEST_NAME]]";
  29. interface I {}
  30. interface J {}
  31. impl forall [T:! I] T as J {}
  32. // CHECK:STDERR: fail_same_self_and_interface_redefined.carbon:[[@LINE+6]]:1: error: redefinition of `impl T as J`
  33. // CHECK:STDERR: impl forall [T:! I] T as J {}
  34. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. // CHECK:STDERR: fail_same_self_and_interface_redefined.carbon:[[@LINE-4]]:1: note: previous definition was here
  36. // CHECK:STDERR: impl forall [T:! I] T as J {}
  37. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  38. impl forall [T:! I] T as J {}
  39. // --- same_type_different_spelling.carbon
  40. library "[[@TEST_NAME]]";
  41. class C;
  42. interface I {}
  43. // We accept this because these two types are spelled differently, even though
  44. // they evaluate to the same type constant. Any use of this impl will be
  45. // ambiguous unless resolved by a `match_first` or similar.
  46. //
  47. // TODO: Produce a warning or maybe an error when this happens in a non-generic
  48. // impl.
  49. impl C as I {}
  50. impl (C, C).0 as I {}
  51. // CHECK:STDOUT: --- same_self_and_interface.carbon
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: constants {
  54. // CHECK:STDOUT: %.1: type = interface_type @Interface [template]
  55. // CHECK:STDOUT: %Self.1: %.1 = bind_symbolic_name Self, 0 [symbolic]
  56. // CHECK:STDOUT: %.2: type = interface_type @I [template]
  57. // CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self, 0 [symbolic]
  58. // CHECK:STDOUT: %.3: type = interface_type @J [template]
  59. // CHECK:STDOUT: %Self.3: %.3 = bind_symbolic_name Self, 0 [symbolic]
  60. // CHECK:STDOUT: %.4: type = interface_type @K [template]
  61. // CHECK:STDOUT: %Self.4: %.4 = bind_symbolic_name Self, 0 [symbolic]
  62. // CHECK:STDOUT: %.5: type = interface_type @L [template]
  63. // CHECK:STDOUT: %Self.5: %.5 = bind_symbolic_name Self, 0 [symbolic]
  64. // CHECK:STDOUT: %T.1: %.2 = bind_symbolic_name T, 0 [symbolic]
  65. // CHECK:STDOUT: %T.2: %.3 = bind_symbolic_name T, 0 [symbolic]
  66. // CHECK:STDOUT: %T.3: %.4 = bind_symbolic_name T, 0 [symbolic]
  67. // CHECK:STDOUT: %T.4: %.5 = bind_symbolic_name T, 0 [symbolic]
  68. // CHECK:STDOUT: %.6: type = tuple_type () [template]
  69. // CHECK:STDOUT: %.7: <witness> = interface_witness () [template]
  70. // CHECK:STDOUT: }
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: file {
  73. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  74. // CHECK:STDOUT: .Interface = %Interface.decl
  75. // CHECK:STDOUT: .I = %I.decl
  76. // CHECK:STDOUT: .J = %J.decl
  77. // CHECK:STDOUT: .K = %K.decl
  78. // CHECK:STDOUT: .L = %L.decl
  79. // CHECK:STDOUT: }
  80. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%.1] {} {}
  81. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.2] {} {}
  82. // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%.3] {} {}
  83. // CHECK:STDOUT: %K.decl: type = interface_decl @K [template = constants.%.4] {} {}
  84. // CHECK:STDOUT: %L.decl: type = interface_decl @L [template = constants.%.5] {} {}
  85. // CHECK:STDOUT: impl_decl @impl.1 [template] {
  86. // CHECK:STDOUT: %T.patt: %.2 = symbolic_binding_pattern T, 0
  87. // CHECK:STDOUT: } {
  88. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.2]
  89. // CHECK:STDOUT: %T.param: %.2 = param T, runtime_param<invalid>
  90. // CHECK:STDOUT: %T.loc11: %.2 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.1)]
  91. // CHECK:STDOUT: %T.ref: %.2 = name_ref T, %T.loc11 [symbolic = %T.1 (constants.%T.1)]
  92. // CHECK:STDOUT: %.loc11_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.1)]
  93. // CHECK:STDOUT: %.loc11_21.2: type = converted %T.ref, %.loc11_21.1 [symbolic = %T.1 (constants.%T.1)]
  94. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT: impl_decl @impl.2 [template] {
  97. // CHECK:STDOUT: %T.patt: %.3 = symbolic_binding_pattern T, 0
  98. // CHECK:STDOUT: } {
  99. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%.3]
  100. // CHECK:STDOUT: %T.param: %.3 = param T, runtime_param<invalid>
  101. // CHECK:STDOUT: %T.loc12: %.3 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.2)]
  102. // CHECK:STDOUT: %T.ref: %.3 = name_ref T, %T.loc12 [symbolic = %T.1 (constants.%T.2)]
  103. // CHECK:STDOUT: %.loc12_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.2)]
  104. // CHECK:STDOUT: %.loc12_21.2: type = converted %T.ref, %.loc12_21.1 [symbolic = %T.1 (constants.%T.2)]
  105. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT: impl_decl @impl.3 [template] {
  108. // CHECK:STDOUT: %T.patt: %.4 = symbolic_binding_pattern T, 0
  109. // CHECK:STDOUT: } {
  110. // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [template = constants.%.4]
  111. // CHECK:STDOUT: %T.param: %.4 = param T, runtime_param<invalid>
  112. // CHECK:STDOUT: %T.loc13: %.4 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.3)]
  113. // CHECK:STDOUT: %T.ref: %.4 = name_ref T, %T.loc13 [symbolic = %T.1 (constants.%T.3)]
  114. // CHECK:STDOUT: %.loc13_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.3)]
  115. // CHECK:STDOUT: %.loc13_21.2: type = converted %T.ref, %.loc13_21.1 [symbolic = %T.1 (constants.%T.3)]
  116. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT: impl_decl @impl.4 [template] {
  119. // CHECK:STDOUT: %T.patt: %.5 = symbolic_binding_pattern T, 0
  120. // CHECK:STDOUT: } {
  121. // CHECK:STDOUT: %L.ref: type = name_ref L, file.%L.decl [template = constants.%.5]
  122. // CHECK:STDOUT: %T.param: %.5 = param T, runtime_param<invalid>
  123. // CHECK:STDOUT: %T.loc14: %.5 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.4)]
  124. // CHECK:STDOUT: %T.ref: %.5 = name_ref T, %T.loc14 [symbolic = %T.1 (constants.%T.4)]
  125. // CHECK:STDOUT: %.loc14_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.4)]
  126. // CHECK:STDOUT: %.loc14_21.2: type = converted %T.ref, %.loc14_21.1 [symbolic = %T.1 (constants.%T.4)]
  127. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: impl_decl @impl.5 [template] {
  130. // CHECK:STDOUT: %T.patt: %.2 = symbolic_binding_pattern T, 0
  131. // CHECK:STDOUT: } {
  132. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.2]
  133. // CHECK:STDOUT: %T.param: %.2 = param T, runtime_param<invalid>
  134. // CHECK:STDOUT: %T.loc18: %.2 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.1)]
  135. // CHECK:STDOUT: %T.ref: %.2 = name_ref T, %T.loc18 [symbolic = %T.1 (constants.%T.1)]
  136. // CHECK:STDOUT: %.loc18_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.1)]
  137. // CHECK:STDOUT: %.loc18_21.2: type = converted %T.ref, %.loc18_21.1 [symbolic = %T.1 (constants.%T.1)]
  138. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT: impl_decl @impl.6 [template] {
  141. // CHECK:STDOUT: %T.patt: %.3 = symbolic_binding_pattern T, 0
  142. // CHECK:STDOUT: } {
  143. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%.3]
  144. // CHECK:STDOUT: %T.param: %.3 = param T, runtime_param<invalid>
  145. // CHECK:STDOUT: %T.loc19: %.3 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.2)]
  146. // CHECK:STDOUT: %T.ref: %.3 = name_ref T, %T.loc19 [symbolic = %T.1 (constants.%T.2)]
  147. // CHECK:STDOUT: %.loc19_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.2)]
  148. // CHECK:STDOUT: %.loc19_21.2: type = converted %T.ref, %.loc19_21.1 [symbolic = %T.1 (constants.%T.2)]
  149. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT: impl_decl @impl.7 [template] {
  152. // CHECK:STDOUT: %T.patt: %.4 = symbolic_binding_pattern T, 0
  153. // CHECK:STDOUT: } {
  154. // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [template = constants.%.4]
  155. // CHECK:STDOUT: %T.param: %.4 = param T, runtime_param<invalid>
  156. // CHECK:STDOUT: %T.loc20: %.4 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.3)]
  157. // CHECK:STDOUT: %T.ref: %.4 = name_ref T, %T.loc20 [symbolic = %T.1 (constants.%T.3)]
  158. // CHECK:STDOUT: %.loc20_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.3)]
  159. // CHECK:STDOUT: %.loc20_21.2: type = converted %T.ref, %.loc20_21.1 [symbolic = %T.1 (constants.%T.3)]
  160. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  161. // CHECK:STDOUT: }
  162. // CHECK:STDOUT: impl_decl @impl.8 [template] {
  163. // CHECK:STDOUT: %T.patt: %.5 = symbolic_binding_pattern T, 0
  164. // CHECK:STDOUT: } {
  165. // CHECK:STDOUT: %L.ref: type = name_ref L, file.%L.decl [template = constants.%.5]
  166. // CHECK:STDOUT: %T.param: %.5 = param T, runtime_param<invalid>
  167. // CHECK:STDOUT: %T.loc21: %.5 = bind_symbolic_name T, 0, %T.param [symbolic = %T.1 (constants.%T.4)]
  168. // CHECK:STDOUT: %T.ref: %.5 = name_ref T, %T.loc21 [symbolic = %T.1 (constants.%T.4)]
  169. // CHECK:STDOUT: %.loc21_21.1: type = facet_type_access %T.ref [symbolic = %T.1 (constants.%T.4)]
  170. // CHECK:STDOUT: %.loc21_21.2: type = converted %T.ref, %.loc21_21.1 [symbolic = %T.1 (constants.%T.4)]
  171. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%.1]
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT: }
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: interface @Interface {
  176. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  177. // CHECK:STDOUT:
  178. // CHECK:STDOUT: !members:
  179. // CHECK:STDOUT: .Self = %Self
  180. // CHECK:STDOUT: witness = ()
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: interface @I {
  184. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: !members:
  187. // CHECK:STDOUT: .Self = %Self
  188. // CHECK:STDOUT: witness = ()
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: interface @J {
  192. // CHECK:STDOUT: %Self: %.3 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.3]
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: !members:
  195. // CHECK:STDOUT: .Self = %Self
  196. // CHECK:STDOUT: witness = ()
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: interface @K {
  200. // CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.4]
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: !members:
  203. // CHECK:STDOUT: .Self = %Self
  204. // CHECK:STDOUT: witness = ()
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: interface @L {
  208. // CHECK:STDOUT: %Self: %.5 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.5]
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: !members:
  211. // CHECK:STDOUT: .Self = %Self
  212. // CHECK:STDOUT: witness = ()
  213. // CHECK:STDOUT: }
  214. // CHECK:STDOUT:
  215. // CHECK:STDOUT: generic impl @impl.1(%T.loc11: %.2) {
  216. // CHECK:STDOUT: %T.1: %.2 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.1)]
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: impl: %.loc11_21.2 as %Interface.ref;
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: generic impl @impl.2(%T.loc12: %.3) {
  222. // CHECK:STDOUT: %T.1: %.3 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.2)]
  223. // CHECK:STDOUT:
  224. // CHECK:STDOUT: impl: %.loc12_21.2 as %Interface.ref;
  225. // CHECK:STDOUT: }
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: generic impl @impl.3(%T.loc13: %.4) {
  228. // CHECK:STDOUT: %T.1: %.4 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.3)]
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: impl: %.loc13_21.2 as %Interface.ref;
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: generic impl @impl.4(%T.loc14: %.5) {
  234. // CHECK:STDOUT: %T.1: %.5 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.4)]
  235. // CHECK:STDOUT:
  236. // CHECK:STDOUT: impl: %.loc14_21.2 as %Interface.ref;
  237. // CHECK:STDOUT: }
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: generic impl @impl.5(%T.loc18: %.2) {
  240. // CHECK:STDOUT: %T.1: %.2 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.1)]
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: impl: %.loc18_21.2 as %Interface.ref {
  243. // CHECK:STDOUT: %.loc18_36: <witness> = interface_witness () [template = constants.%.7]
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: !members:
  246. // CHECK:STDOUT: witness = %.loc18_36
  247. // CHECK:STDOUT: }
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: generic impl @impl.6(%T.loc19: %.3) {
  251. // CHECK:STDOUT: %T.1: %.3 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.2)]
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: impl: %.loc19_21.2 as %Interface.ref {
  254. // CHECK:STDOUT: %.loc19_36: <witness> = interface_witness () [template = constants.%.7]
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: !members:
  257. // CHECK:STDOUT: witness = %.loc19_36
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: generic impl @impl.7(%T.loc20: %.4) {
  262. // CHECK:STDOUT: %T.1: %.4 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.3)]
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: impl: %.loc20_21.2 as %Interface.ref {
  265. // CHECK:STDOUT: %.loc20_36: <witness> = interface_witness () [template = constants.%.7]
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: !members:
  268. // CHECK:STDOUT: witness = %.loc20_36
  269. // CHECK:STDOUT: }
  270. // CHECK:STDOUT: }
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: generic impl @impl.8(%T.loc21: %.5) {
  273. // CHECK:STDOUT: %T.1: %.5 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T.4)]
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: impl: %.loc21_21.2 as %Interface.ref {
  276. // CHECK:STDOUT: %.loc21_36: <witness> = interface_witness () [template = constants.%.7]
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: !members:
  279. // CHECK:STDOUT: witness = %.loc21_36
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT: }
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: specific @impl.1(constants.%T.1) {
  284. // CHECK:STDOUT: %T.1 => constants.%T.1
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: specific @impl.2(constants.%T.2) {
  288. // CHECK:STDOUT: %T.1 => constants.%T.2
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: specific @impl.3(constants.%T.3) {
  292. // CHECK:STDOUT: %T.1 => constants.%T.3
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: specific @impl.4(constants.%T.4) {
  296. // CHECK:STDOUT: %T.1 => constants.%T.4
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: specific @impl.5(constants.%T.1) {
  300. // CHECK:STDOUT: %T.1 => constants.%T.1
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: specific @impl.6(constants.%T.2) {
  304. // CHECK:STDOUT: %T.1 => constants.%T.2
  305. // CHECK:STDOUT: }
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: specific @impl.7(constants.%T.3) {
  308. // CHECK:STDOUT: %T.1 => constants.%T.3
  309. // CHECK:STDOUT: }
  310. // CHECK:STDOUT:
  311. // CHECK:STDOUT: specific @impl.8(constants.%T.4) {
  312. // CHECK:STDOUT: %T.1 => constants.%T.4
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: --- fail_same_self_and_interface_redefined.carbon
  316. // CHECK:STDOUT:
  317. // CHECK:STDOUT: constants {
  318. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  319. // CHECK:STDOUT: %Self.1: %.1 = bind_symbolic_name Self, 0 [symbolic]
  320. // CHECK:STDOUT: %.2: type = interface_type @J [template]
  321. // CHECK:STDOUT: %Self.2: %.2 = bind_symbolic_name Self, 0 [symbolic]
  322. // CHECK:STDOUT: %T: %.1 = bind_symbolic_name T, 0 [symbolic]
  323. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  324. // CHECK:STDOUT: %.4: <witness> = interface_witness () [template]
  325. // CHECK:STDOUT: }
  326. // CHECK:STDOUT:
  327. // CHECK:STDOUT: file {
  328. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  329. // CHECK:STDOUT: .I = %I.decl
  330. // CHECK:STDOUT: .J = %J.decl
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} {}
  333. // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%.2] {} {}
  334. // CHECK:STDOUT: impl_decl @impl [template] {
  335. // CHECK:STDOUT: %T.patt: %.1 = symbolic_binding_pattern T, 0
  336. // CHECK:STDOUT: } {
  337. // CHECK:STDOUT: %I.ref.loc7: type = name_ref I, file.%I.decl [template = constants.%.1]
  338. // CHECK:STDOUT: %T.param.loc7: %.1 = param T, runtime_param<invalid>
  339. // CHECK:STDOUT: %T.loc7: %.1 = bind_symbolic_name T, 0, %T.param.loc7 [symbolic = %T.1 (constants.%T)]
  340. // CHECK:STDOUT: %T.ref.loc7: %.1 = name_ref T, %T.loc7 [symbolic = %T.1 (constants.%T)]
  341. // CHECK:STDOUT: %.loc7_21.1: type = facet_type_access %T.ref.loc7 [symbolic = %T.1 (constants.%T)]
  342. // CHECK:STDOUT: %.loc7_21.2: type = converted %T.ref.loc7, %.loc7_21.1 [symbolic = %T.1 (constants.%T)]
  343. // CHECK:STDOUT: %J.ref.loc7: type = name_ref J, file.%J.decl [template = constants.%.2]
  344. // CHECK:STDOUT: }
  345. // CHECK:STDOUT: impl_decl @impl [template] {
  346. // CHECK:STDOUT: %T.patt: %.1 = symbolic_binding_pattern T, 0
  347. // CHECK:STDOUT: } {
  348. // CHECK:STDOUT: %I.ref.loc14: type = name_ref I, file.%I.decl [template = constants.%.1]
  349. // CHECK:STDOUT: %T.param.loc14: %.1 = param T, runtime_param<invalid>
  350. // CHECK:STDOUT: %T.loc14: %.1 = bind_symbolic_name T, 0, %T.param.loc14 [symbolic = constants.%T]
  351. // CHECK:STDOUT: %T.ref.loc14: %.1 = name_ref T, %T.loc14 [symbolic = constants.%T]
  352. // CHECK:STDOUT: %.loc14_21.1: type = facet_type_access %T.ref.loc14 [symbolic = constants.%T]
  353. // CHECK:STDOUT: %.loc14_21.2: type = converted %T.ref.loc14, %.loc14_21.1 [symbolic = constants.%T]
  354. // CHECK:STDOUT: %J.ref.loc14: type = name_ref J, file.%J.decl [template = constants.%.2]
  355. // CHECK:STDOUT: }
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: interface @I {
  359. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: !members:
  362. // CHECK:STDOUT: .Self = %Self
  363. // CHECK:STDOUT: witness = ()
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: interface @J {
  367. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
  368. // CHECK:STDOUT:
  369. // CHECK:STDOUT: !members:
  370. // CHECK:STDOUT: .Self = %Self
  371. // CHECK:STDOUT: witness = ()
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: generic impl @impl(%T.loc7: %.1) {
  375. // CHECK:STDOUT: %T.1: %.1 = bind_symbolic_name T, 0 [symbolic = %T.1 (constants.%T)]
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: impl: %.loc7_21.2 as %J.ref.loc7 {
  378. // CHECK:STDOUT: !members:
  379. // CHECK:STDOUT: witness = <unexpected>.inst+21.loc7_28
  380. // CHECK:STDOUT: }
  381. // CHECK:STDOUT: }
  382. // CHECK:STDOUT:
  383. // CHECK:STDOUT: specific @impl(constants.%T) {
  384. // CHECK:STDOUT: %T.1 => constants.%T
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT:
  387. // CHECK:STDOUT: --- same_type_different_spelling.carbon
  388. // CHECK:STDOUT:
  389. // CHECK:STDOUT: constants {
  390. // CHECK:STDOUT: %C: type = class_type @C [template]
  391. // CHECK:STDOUT: %.1: type = interface_type @I [template]
  392. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self, 0 [symbolic]
  393. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  394. // CHECK:STDOUT: %.3: <witness> = interface_witness () [template]
  395. // CHECK:STDOUT: %.4: type = tuple_type (type, type) [template]
  396. // CHECK:STDOUT: %.5: i32 = int_literal 0 [template]
  397. // CHECK:STDOUT: %.6: type = ptr_type %.4 [template]
  398. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%C, %C) [template]
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT:
  401. // CHECK:STDOUT: file {
  402. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  403. // CHECK:STDOUT: .C = %C.decl
  404. // CHECK:STDOUT: .I = %I.decl
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  407. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%.1] {} {}
  408. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  409. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  410. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  411. // CHECK:STDOUT: }
  412. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  413. // CHECK:STDOUT: %C.ref.loc14_7: type = name_ref C, file.%C.decl [template = constants.%C]
  414. // CHECK:STDOUT: %C.ref.loc14_10: type = name_ref C, file.%C.decl [template = constants.%C]
  415. // CHECK:STDOUT: %.loc14_11.1: %.4 = tuple_literal (%C.ref.loc14_7, %C.ref.loc14_10)
  416. // CHECK:STDOUT: %.loc14_13: i32 = int_literal 0 [template = constants.%.5]
  417. // CHECK:STDOUT: %tuple: %.4 = tuple_value (%C.ref.loc14_7, %C.ref.loc14_10) [template = constants.%tuple]
  418. // CHECK:STDOUT: %.loc14_11.2: %.4 = converted %.loc14_11.1, %tuple [template = constants.%tuple]
  419. // CHECK:STDOUT: %.loc14_12: type = tuple_access %.loc14_11.2, element0 [template = constants.%C]
  420. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%.1]
  421. // CHECK:STDOUT: }
  422. // CHECK:STDOUT: }
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: interface @I {
  425. // CHECK:STDOUT: %Self: %.1 = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: !members:
  428. // CHECK:STDOUT: .Self = %Self
  429. // CHECK:STDOUT: witness = ()
  430. // CHECK:STDOUT: }
  431. // CHECK:STDOUT:
  432. // CHECK:STDOUT: impl @impl.1: %C.ref as %I.ref {
  433. // CHECK:STDOUT: %.loc13: <witness> = interface_witness () [template = constants.%.3]
  434. // CHECK:STDOUT:
  435. // CHECK:STDOUT: !members:
  436. // CHECK:STDOUT: witness = %.loc13
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: impl @impl.2: %.loc14_12 as %I.ref {
  440. // CHECK:STDOUT: %.loc14_20: <witness> = interface_witness () [template = constants.%.3]
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: !members:
  443. // CHECK:STDOUT: witness = %.loc14_20
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT:
  446. // CHECK:STDOUT: class @C;
  447. // CHECK:STDOUT: