generic_redeclaration.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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` [ImplRedefinition]
  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 [ImplPreviousDefinition]
  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: %Interface.type: type = facet_type <@Interface> [template]
  55. // CHECK:STDOUT: %Self.1: %Interface.type = bind_symbolic_name Self, 0 [symbolic]
  56. // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
  57. // CHECK:STDOUT: %Self.2: %I.type = bind_symbolic_name Self, 0 [symbolic]
  58. // CHECK:STDOUT: %J.type: type = facet_type <@J> [template]
  59. // CHECK:STDOUT: %Self.3: %J.type = bind_symbolic_name Self, 0 [symbolic]
  60. // CHECK:STDOUT: %K.type: type = facet_type <@K> [template]
  61. // CHECK:STDOUT: %Self.4: %K.type = bind_symbolic_name Self, 0 [symbolic]
  62. // CHECK:STDOUT: %L.type: type = facet_type <@L> [template]
  63. // CHECK:STDOUT: %Self.5: %L.type = bind_symbolic_name Self, 0 [symbolic]
  64. // CHECK:STDOUT: %T.1: %I.type = bind_symbolic_name T, 0 [symbolic]
  65. // CHECK:STDOUT: %T.patt.1: %I.type = symbolic_binding_pattern T, 0 [symbolic]
  66. // CHECK:STDOUT: %T.2: %J.type = bind_symbolic_name T, 0 [symbolic]
  67. // CHECK:STDOUT: %T.patt.2: %J.type = symbolic_binding_pattern T, 0 [symbolic]
  68. // CHECK:STDOUT: %T.3: %K.type = bind_symbolic_name T, 0 [symbolic]
  69. // CHECK:STDOUT: %T.patt.3: %K.type = symbolic_binding_pattern T, 0 [symbolic]
  70. // CHECK:STDOUT: %T.4: %L.type = bind_symbolic_name T, 0 [symbolic]
  71. // CHECK:STDOUT: %T.patt.4: %L.type = symbolic_binding_pattern T, 0 [symbolic]
  72. // CHECK:STDOUT: %.1: <witness> = interface_witness () [template]
  73. // CHECK:STDOUT: }
  74. // CHECK:STDOUT:
  75. // CHECK:STDOUT: file {
  76. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  77. // CHECK:STDOUT: .Interface = %Interface.decl
  78. // CHECK:STDOUT: .I = %I.decl
  79. // CHECK:STDOUT: .J = %J.decl
  80. // CHECK:STDOUT: .K = %K.decl
  81. // CHECK:STDOUT: .L = %L.decl
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %Interface.decl: type = interface_decl @Interface [template = constants.%Interface.type] {} {}
  84. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  85. // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {}
  86. // CHECK:STDOUT: %K.decl: type = interface_decl @K [template = constants.%K.type] {} {}
  87. // CHECK:STDOUT: %L.decl: type = interface_decl @L [template = constants.%L.type] {} {}
  88. // CHECK:STDOUT: impl_decl @impl.1 [template] {
  89. // CHECK:STDOUT: %T.patt.loc11_14.1: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_14.2 (constants.%T.patt.1)]
  90. // CHECK:STDOUT: %T.param_patt: %I.type = value_param_pattern %T.patt.loc11_14.1, runtime_param<invalid> [symbolic = %T.patt.loc11_14.2 (constants.%T.patt.1)]
  91. // CHECK:STDOUT: } {
  92. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  93. // CHECK:STDOUT: %T.ref: %I.type = name_ref T, %T.loc11_14.1 [symbolic = %T.loc11_14.2 (constants.%T.1)]
  94. // CHECK:STDOUT: %.loc11_21.1: type = facet_type_access %T.ref [symbolic = %T.loc11_14.2 (constants.%T.1)]
  95. // CHECK:STDOUT: %.loc11_21.2: type = converted %T.ref, %.loc11_21.1 [symbolic = %T.loc11_14.2 (constants.%T.1)]
  96. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  97. // CHECK:STDOUT: %T.param: %I.type = value_param runtime_param<invalid>
  98. // CHECK:STDOUT: %T.loc11_14.1: %I.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc11_14.2 (constants.%T.1)]
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT: impl_decl @impl.2 [template] {
  101. // CHECK:STDOUT: %T.patt.loc12_14.1: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_14.2 (constants.%T.patt.2)]
  102. // CHECK:STDOUT: %T.param_patt: %J.type = value_param_pattern %T.patt.loc12_14.1, runtime_param<invalid> [symbolic = %T.patt.loc12_14.2 (constants.%T.patt.2)]
  103. // CHECK:STDOUT: } {
  104. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type]
  105. // CHECK:STDOUT: %T.ref: %J.type = name_ref T, %T.loc12_14.1 [symbolic = %T.loc12_14.2 (constants.%T.2)]
  106. // CHECK:STDOUT: %.loc12_21.1: type = facet_type_access %T.ref [symbolic = %T.loc12_14.2 (constants.%T.2)]
  107. // CHECK:STDOUT: %.loc12_21.2: type = converted %T.ref, %.loc12_21.1 [symbolic = %T.loc12_14.2 (constants.%T.2)]
  108. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  109. // CHECK:STDOUT: %T.param: %J.type = value_param runtime_param<invalid>
  110. // CHECK:STDOUT: %T.loc12_14.1: %J.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc12_14.2 (constants.%T.2)]
  111. // CHECK:STDOUT: }
  112. // CHECK:STDOUT: impl_decl @impl.3 [template] {
  113. // CHECK:STDOUT: %T.patt.loc13_14.1: %K.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_14.2 (constants.%T.patt.3)]
  114. // CHECK:STDOUT: %T.param_patt: %K.type = value_param_pattern %T.patt.loc13_14.1, runtime_param<invalid> [symbolic = %T.patt.loc13_14.2 (constants.%T.patt.3)]
  115. // CHECK:STDOUT: } {
  116. // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [template = constants.%K.type]
  117. // CHECK:STDOUT: %T.ref: %K.type = name_ref T, %T.loc13_14.1 [symbolic = %T.loc13_14.2 (constants.%T.3)]
  118. // CHECK:STDOUT: %.loc13_21.1: type = facet_type_access %T.ref [symbolic = %T.loc13_14.2 (constants.%T.3)]
  119. // CHECK:STDOUT: %.loc13_21.2: type = converted %T.ref, %.loc13_21.1 [symbolic = %T.loc13_14.2 (constants.%T.3)]
  120. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  121. // CHECK:STDOUT: %T.param: %K.type = value_param runtime_param<invalid>
  122. // CHECK:STDOUT: %T.loc13_14.1: %K.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc13_14.2 (constants.%T.3)]
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: impl_decl @impl.4 [template] {
  125. // CHECK:STDOUT: %T.patt.loc14_14.1: %L.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc14_14.2 (constants.%T.patt.4)]
  126. // CHECK:STDOUT: %T.param_patt: %L.type = value_param_pattern %T.patt.loc14_14.1, runtime_param<invalid> [symbolic = %T.patt.loc14_14.2 (constants.%T.patt.4)]
  127. // CHECK:STDOUT: } {
  128. // CHECK:STDOUT: %L.ref: type = name_ref L, file.%L.decl [template = constants.%L.type]
  129. // CHECK:STDOUT: %T.ref: %L.type = name_ref T, %T.loc14_14.1 [symbolic = %T.loc14_14.2 (constants.%T.4)]
  130. // CHECK:STDOUT: %.loc14_21.1: type = facet_type_access %T.ref [symbolic = %T.loc14_14.2 (constants.%T.4)]
  131. // CHECK:STDOUT: %.loc14_21.2: type = converted %T.ref, %.loc14_21.1 [symbolic = %T.loc14_14.2 (constants.%T.4)]
  132. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  133. // CHECK:STDOUT: %T.param: %L.type = value_param runtime_param<invalid>
  134. // CHECK:STDOUT: %T.loc14_14.1: %L.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc14_14.2 (constants.%T.4)]
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT: impl_decl @impl.5 [template] {
  137. // CHECK:STDOUT: %T.patt.loc18_14.1: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc18_14.2 (constants.%T.patt.1)]
  138. // CHECK:STDOUT: %T.param_patt: %I.type = value_param_pattern %T.patt.loc18_14.1, runtime_param<invalid> [symbolic = %T.patt.loc18_14.2 (constants.%T.patt.1)]
  139. // CHECK:STDOUT: } {
  140. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  141. // CHECK:STDOUT: %T.ref: %I.type = name_ref T, %T.loc18_14.1 [symbolic = %T.loc18_14.2 (constants.%T.1)]
  142. // CHECK:STDOUT: %.loc18_21.1: type = facet_type_access %T.ref [symbolic = %T.loc18_14.2 (constants.%T.1)]
  143. // CHECK:STDOUT: %.loc18_21.2: type = converted %T.ref, %.loc18_21.1 [symbolic = %T.loc18_14.2 (constants.%T.1)]
  144. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  145. // CHECK:STDOUT: %T.param: %I.type = value_param runtime_param<invalid>
  146. // CHECK:STDOUT: %T.loc18_14.1: %I.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc18_14.2 (constants.%T.1)]
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: impl_decl @impl.6 [template] {
  149. // CHECK:STDOUT: %T.patt.loc19_14.1: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc19_14.2 (constants.%T.patt.2)]
  150. // CHECK:STDOUT: %T.param_patt: %J.type = value_param_pattern %T.patt.loc19_14.1, runtime_param<invalid> [symbolic = %T.patt.loc19_14.2 (constants.%T.patt.2)]
  151. // CHECK:STDOUT: } {
  152. // CHECK:STDOUT: %J.ref: type = name_ref J, file.%J.decl [template = constants.%J.type]
  153. // CHECK:STDOUT: %T.ref: %J.type = name_ref T, %T.loc19_14.1 [symbolic = %T.loc19_14.2 (constants.%T.2)]
  154. // CHECK:STDOUT: %.loc19_21.1: type = facet_type_access %T.ref [symbolic = %T.loc19_14.2 (constants.%T.2)]
  155. // CHECK:STDOUT: %.loc19_21.2: type = converted %T.ref, %.loc19_21.1 [symbolic = %T.loc19_14.2 (constants.%T.2)]
  156. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  157. // CHECK:STDOUT: %T.param: %J.type = value_param runtime_param<invalid>
  158. // CHECK:STDOUT: %T.loc19_14.1: %J.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc19_14.2 (constants.%T.2)]
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT: impl_decl @impl.7 [template] {
  161. // CHECK:STDOUT: %T.patt.loc20_14.1: %K.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc20_14.2 (constants.%T.patt.3)]
  162. // CHECK:STDOUT: %T.param_patt: %K.type = value_param_pattern %T.patt.loc20_14.1, runtime_param<invalid> [symbolic = %T.patt.loc20_14.2 (constants.%T.patt.3)]
  163. // CHECK:STDOUT: } {
  164. // CHECK:STDOUT: %K.ref: type = name_ref K, file.%K.decl [template = constants.%K.type]
  165. // CHECK:STDOUT: %T.ref: %K.type = name_ref T, %T.loc20_14.1 [symbolic = %T.loc20_14.2 (constants.%T.3)]
  166. // CHECK:STDOUT: %.loc20_21.1: type = facet_type_access %T.ref [symbolic = %T.loc20_14.2 (constants.%T.3)]
  167. // CHECK:STDOUT: %.loc20_21.2: type = converted %T.ref, %.loc20_21.1 [symbolic = %T.loc20_14.2 (constants.%T.3)]
  168. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  169. // CHECK:STDOUT: %T.param: %K.type = value_param runtime_param<invalid>
  170. // CHECK:STDOUT: %T.loc20_14.1: %K.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc20_14.2 (constants.%T.3)]
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT: impl_decl @impl.8 [template] {
  173. // CHECK:STDOUT: %T.patt.loc21_14.1: %L.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt.4)]
  174. // CHECK:STDOUT: %T.param_patt: %L.type = value_param_pattern %T.patt.loc21_14.1, runtime_param<invalid> [symbolic = %T.patt.loc21_14.2 (constants.%T.patt.4)]
  175. // CHECK:STDOUT: } {
  176. // CHECK:STDOUT: %L.ref: type = name_ref L, file.%L.decl [template = constants.%L.type]
  177. // CHECK:STDOUT: %T.ref: %L.type = name_ref T, %T.loc21_14.1 [symbolic = %T.loc21_14.2 (constants.%T.4)]
  178. // CHECK:STDOUT: %.loc21_21.1: type = facet_type_access %T.ref [symbolic = %T.loc21_14.2 (constants.%T.4)]
  179. // CHECK:STDOUT: %.loc21_21.2: type = converted %T.ref, %.loc21_21.1 [symbolic = %T.loc21_14.2 (constants.%T.4)]
  180. // CHECK:STDOUT: %Interface.ref: type = name_ref Interface, file.%Interface.decl [template = constants.%Interface.type]
  181. // CHECK:STDOUT: %T.param: %L.type = value_param runtime_param<invalid>
  182. // CHECK:STDOUT: %T.loc21_14.1: %L.type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc21_14.2 (constants.%T.4)]
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: interface @Interface {
  187. // CHECK:STDOUT: %Self: %Interface.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: !members:
  190. // CHECK:STDOUT: .Self = %Self
  191. // CHECK:STDOUT: witness = ()
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT:
  194. // CHECK:STDOUT: interface @I {
  195. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
  196. // CHECK:STDOUT:
  197. // CHECK:STDOUT: !members:
  198. // CHECK:STDOUT: .Self = %Self
  199. // CHECK:STDOUT: witness = ()
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: interface @J {
  203. // CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.3]
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: !members:
  206. // CHECK:STDOUT: .Self = %Self
  207. // CHECK:STDOUT: witness = ()
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: interface @K {
  211. // CHECK:STDOUT: %Self: %K.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.4]
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: !members:
  214. // CHECK:STDOUT: .Self = %Self
  215. // CHECK:STDOUT: witness = ()
  216. // CHECK:STDOUT: }
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: interface @L {
  219. // CHECK:STDOUT: %Self: %L.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.5]
  220. // CHECK:STDOUT:
  221. // CHECK:STDOUT: !members:
  222. // CHECK:STDOUT: .Self = %Self
  223. // CHECK:STDOUT: witness = ()
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: generic impl @impl.1(%T.loc11_14.1: %I.type) {
  227. // CHECK:STDOUT: %T.loc11_14.2: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc11_14.2 (constants.%T.1)]
  228. // CHECK:STDOUT: %T.patt.loc11_14.2: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc11_14.2 (constants.%T.patt.1)]
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: impl: %.loc11_21.2 as %Interface.ref;
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: generic impl @impl.2(%T.loc12_14.1: %J.type) {
  234. // CHECK:STDOUT: %T.loc12_14.2: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc12_14.2 (constants.%T.2)]
  235. // CHECK:STDOUT: %T.patt.loc12_14.2: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc12_14.2 (constants.%T.patt.2)]
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: impl: %.loc12_21.2 as %Interface.ref;
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: generic impl @impl.3(%T.loc13_14.1: %K.type) {
  241. // CHECK:STDOUT: %T.loc13_14.2: %K.type = bind_symbolic_name T, 0 [symbolic = %T.loc13_14.2 (constants.%T.3)]
  242. // CHECK:STDOUT: %T.patt.loc13_14.2: %K.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc13_14.2 (constants.%T.patt.3)]
  243. // CHECK:STDOUT:
  244. // CHECK:STDOUT: impl: %.loc13_21.2 as %Interface.ref;
  245. // CHECK:STDOUT: }
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: generic impl @impl.4(%T.loc14_14.1: %L.type) {
  248. // CHECK:STDOUT: %T.loc14_14.2: %L.type = bind_symbolic_name T, 0 [symbolic = %T.loc14_14.2 (constants.%T.4)]
  249. // CHECK:STDOUT: %T.patt.loc14_14.2: %L.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc14_14.2 (constants.%T.patt.4)]
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: impl: %.loc14_21.2 as %Interface.ref;
  252. // CHECK:STDOUT: }
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: generic impl @impl.5(%T.loc18_14.1: %I.type) {
  255. // CHECK:STDOUT: %T.loc18_14.2: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc18_14.2 (constants.%T.1)]
  256. // CHECK:STDOUT: %T.patt.loc18_14.2: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc18_14.2 (constants.%T.patt.1)]
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: !definition:
  259. // CHECK:STDOUT:
  260. // CHECK:STDOUT: impl: %.loc18_21.2 as %Interface.ref {
  261. // CHECK:STDOUT: %.loc18_36: <witness> = interface_witness () [template = constants.%.1]
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: !members:
  264. // CHECK:STDOUT: witness = %.loc18_36
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT: }
  267. // CHECK:STDOUT:
  268. // CHECK:STDOUT: generic impl @impl.6(%T.loc19_14.1: %J.type) {
  269. // CHECK:STDOUT: %T.loc19_14.2: %J.type = bind_symbolic_name T, 0 [symbolic = %T.loc19_14.2 (constants.%T.2)]
  270. // CHECK:STDOUT: %T.patt.loc19_14.2: %J.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc19_14.2 (constants.%T.patt.2)]
  271. // CHECK:STDOUT:
  272. // CHECK:STDOUT: !definition:
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: impl: %.loc19_21.2 as %Interface.ref {
  275. // CHECK:STDOUT: %.loc19_36: <witness> = interface_witness () [template = constants.%.1]
  276. // CHECK:STDOUT:
  277. // CHECK:STDOUT: !members:
  278. // CHECK:STDOUT: witness = %.loc19_36
  279. // CHECK:STDOUT: }
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: generic impl @impl.7(%T.loc20_14.1: %K.type) {
  283. // CHECK:STDOUT: %T.loc20_14.2: %K.type = bind_symbolic_name T, 0 [symbolic = %T.loc20_14.2 (constants.%T.3)]
  284. // CHECK:STDOUT: %T.patt.loc20_14.2: %K.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc20_14.2 (constants.%T.patt.3)]
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: !definition:
  287. // CHECK:STDOUT:
  288. // CHECK:STDOUT: impl: %.loc20_21.2 as %Interface.ref {
  289. // CHECK:STDOUT: %.loc20_36: <witness> = interface_witness () [template = constants.%.1]
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: !members:
  292. // CHECK:STDOUT: witness = %.loc20_36
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: generic impl @impl.8(%T.loc21_14.1: %L.type) {
  297. // CHECK:STDOUT: %T.loc21_14.2: %L.type = bind_symbolic_name T, 0 [symbolic = %T.loc21_14.2 (constants.%T.4)]
  298. // CHECK:STDOUT: %T.patt.loc21_14.2: %L.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc21_14.2 (constants.%T.patt.4)]
  299. // CHECK:STDOUT:
  300. // CHECK:STDOUT: !definition:
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: impl: %.loc21_21.2 as %Interface.ref {
  303. // CHECK:STDOUT: %.loc21_36: <witness> = interface_witness () [template = constants.%.1]
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: !members:
  306. // CHECK:STDOUT: witness = %.loc21_36
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT:
  310. // CHECK:STDOUT: specific @impl.1(constants.%T.1) {
  311. // CHECK:STDOUT: %T.loc11_14.2 => constants.%T.1
  312. // CHECK:STDOUT: %T.patt.loc11_14.2 => constants.%T.1
  313. // CHECK:STDOUT: }
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: specific @impl.2(constants.%T.2) {
  316. // CHECK:STDOUT: %T.loc12_14.2 => constants.%T.2
  317. // CHECK:STDOUT: %T.patt.loc12_14.2 => constants.%T.2
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: specific @impl.3(constants.%T.3) {
  321. // CHECK:STDOUT: %T.loc13_14.2 => constants.%T.3
  322. // CHECK:STDOUT: %T.patt.loc13_14.2 => constants.%T.3
  323. // CHECK:STDOUT: }
  324. // CHECK:STDOUT:
  325. // CHECK:STDOUT: specific @impl.4(constants.%T.4) {
  326. // CHECK:STDOUT: %T.loc14_14.2 => constants.%T.4
  327. // CHECK:STDOUT: %T.patt.loc14_14.2 => constants.%T.4
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: specific @impl.5(constants.%T.1) {
  331. // CHECK:STDOUT: %T.loc18_14.2 => constants.%T.1
  332. // CHECK:STDOUT: %T.patt.loc18_14.2 => constants.%T.1
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: specific @impl.6(constants.%T.2) {
  336. // CHECK:STDOUT: %T.loc19_14.2 => constants.%T.2
  337. // CHECK:STDOUT: %T.patt.loc19_14.2 => constants.%T.2
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: specific @impl.7(constants.%T.3) {
  341. // CHECK:STDOUT: %T.loc20_14.2 => constants.%T.3
  342. // CHECK:STDOUT: %T.patt.loc20_14.2 => constants.%T.3
  343. // CHECK:STDOUT: }
  344. // CHECK:STDOUT:
  345. // CHECK:STDOUT: specific @impl.8(constants.%T.4) {
  346. // CHECK:STDOUT: %T.loc21_14.2 => constants.%T.4
  347. // CHECK:STDOUT: %T.patt.loc21_14.2 => constants.%T.4
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: --- fail_same_self_and_interface_redefined.carbon
  351. // CHECK:STDOUT:
  352. // CHECK:STDOUT: constants {
  353. // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
  354. // CHECK:STDOUT: %Self.1: %I.type = bind_symbolic_name Self, 0 [symbolic]
  355. // CHECK:STDOUT: %J.type: type = facet_type <@J> [template]
  356. // CHECK:STDOUT: %Self.2: %J.type = bind_symbolic_name Self, 0 [symbolic]
  357. // CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic]
  358. // CHECK:STDOUT: %T.patt: %I.type = symbolic_binding_pattern T, 0 [symbolic]
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT:
  361. // CHECK:STDOUT: file {
  362. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  363. // CHECK:STDOUT: .I = %I.decl
  364. // CHECK:STDOUT: .J = %J.decl
  365. // CHECK:STDOUT: }
  366. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  367. // CHECK:STDOUT: %J.decl: type = interface_decl @J [template = constants.%J.type] {} {}
  368. // CHECK:STDOUT: impl_decl @impl [template] {
  369. // CHECK:STDOUT: %T.patt.loc7_14.1: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_14.2 (constants.%T.patt)]
  370. // CHECK:STDOUT: %T.param_patt: %I.type = value_param_pattern %T.patt.loc7_14.1, runtime_param<invalid> [symbolic = %T.patt.loc7_14.2 (constants.%T.patt)]
  371. // CHECK:STDOUT: } {
  372. // CHECK:STDOUT: %I.ref.loc7: type = name_ref I, file.%I.decl [template = constants.%I.type]
  373. // CHECK:STDOUT: %T.ref.loc7: %I.type = name_ref T, %T.loc7_14.1 [symbolic = %T.loc7_14.2 (constants.%T)]
  374. // CHECK:STDOUT: %.loc7_21.1: type = facet_type_access %T.ref.loc7 [symbolic = %T.loc7_14.2 (constants.%T)]
  375. // CHECK:STDOUT: %.loc7_21.2: type = converted %T.ref.loc7, %.loc7_21.1 [symbolic = %T.loc7_14.2 (constants.%T)]
  376. // CHECK:STDOUT: %J.ref.loc7: type = name_ref J, file.%J.decl [template = constants.%J.type]
  377. // CHECK:STDOUT: %T.param.loc7: %I.type = value_param runtime_param<invalid>
  378. // CHECK:STDOUT: %T.loc7_14.1: %I.type = bind_symbolic_name T, 0, %T.param.loc7 [symbolic = %T.loc7_14.2 (constants.%T)]
  379. // CHECK:STDOUT: }
  380. // CHECK:STDOUT: impl_decl @impl [template] {
  381. // CHECK:STDOUT: %T.patt.loc7_14.1: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_14.2 (constants.%T.patt)]
  382. // CHECK:STDOUT: %T.param_patt: %I.type = value_param_pattern %T.patt.loc7_14.1, runtime_param<invalid> [symbolic = %T.patt.loc7_14.2 (constants.%T.patt)]
  383. // CHECK:STDOUT: } {
  384. // CHECK:STDOUT: %I.ref.loc14: type = name_ref I, file.%I.decl [template = constants.%I.type]
  385. // CHECK:STDOUT: %T.ref.loc14: %I.type = name_ref T, %T.loc14 [symbolic = constants.%T]
  386. // CHECK:STDOUT: %.loc14_21.1: type = facet_type_access %T.ref.loc14 [symbolic = constants.%T]
  387. // CHECK:STDOUT: %.loc14_21.2: type = converted %T.ref.loc14, %.loc14_21.1 [symbolic = constants.%T]
  388. // CHECK:STDOUT: %J.ref.loc14: type = name_ref J, file.%J.decl [template = constants.%J.type]
  389. // CHECK:STDOUT: %T.param.loc14: %I.type = value_param runtime_param<invalid>
  390. // CHECK:STDOUT: %T.loc14: %I.type = bind_symbolic_name T, 0, %T.param.loc14 [symbolic = constants.%T]
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: interface @I {
  395. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.1]
  396. // CHECK:STDOUT:
  397. // CHECK:STDOUT: !members:
  398. // CHECK:STDOUT: .Self = %Self
  399. // CHECK:STDOUT: witness = ()
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: interface @J {
  403. // CHECK:STDOUT: %Self: %J.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self.2]
  404. // CHECK:STDOUT:
  405. // CHECK:STDOUT: !members:
  406. // CHECK:STDOUT: .Self = %Self
  407. // CHECK:STDOUT: witness = ()
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: generic impl @impl(%T.loc7_14.1: %I.type) {
  411. // CHECK:STDOUT: %T.loc7_14.2: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc7_14.2 (constants.%T)]
  412. // CHECK:STDOUT: %T.patt.loc7_14.2: %I.type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc7_14.2 (constants.%T.patt)]
  413. // CHECK:STDOUT:
  414. // CHECK:STDOUT: !definition:
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: impl: %.loc7_21.2 as %J.ref.loc7 {
  417. // CHECK:STDOUT: !members:
  418. // CHECK:STDOUT: witness = <unexpected>.inst+24.loc7_28
  419. // CHECK:STDOUT: }
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: specific @impl(constants.%T) {
  423. // CHECK:STDOUT: %T.loc7_14.2 => constants.%T
  424. // CHECK:STDOUT: %T.patt.loc7_14.2 => constants.%T
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: --- same_type_different_spelling.carbon
  428. // CHECK:STDOUT:
  429. // CHECK:STDOUT: constants {
  430. // CHECK:STDOUT: %C: type = class_type @C [template]
  431. // CHECK:STDOUT: %I.type: type = facet_type <@I> [template]
  432. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  433. // CHECK:STDOUT: %.1: <witness> = interface_witness () [template]
  434. // CHECK:STDOUT: %tuple.type: type = tuple_type (type, type) [template]
  435. // CHECK:STDOUT: %.2: Core.IntLiteral = int_value 0 [template]
  436. // CHECK:STDOUT: %tuple: %tuple.type = tuple_value (%C, %C) [template]
  437. // CHECK:STDOUT: }
  438. // CHECK:STDOUT:
  439. // CHECK:STDOUT: file {
  440. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  441. // CHECK:STDOUT: .C = %C.decl
  442. // CHECK:STDOUT: .I = %I.decl
  443. // CHECK:STDOUT: }
  444. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {} {}
  445. // CHECK:STDOUT: %I.decl: type = interface_decl @I [template = constants.%I.type] {} {}
  446. // CHECK:STDOUT: impl_decl @impl.1 [template] {} {
  447. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [template = constants.%C]
  448. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  449. // CHECK:STDOUT: }
  450. // CHECK:STDOUT: impl_decl @impl.2 [template] {} {
  451. // CHECK:STDOUT: %C.ref.loc14_7: type = name_ref C, file.%C.decl [template = constants.%C]
  452. // CHECK:STDOUT: %C.ref.loc14_10: type = name_ref C, file.%C.decl [template = constants.%C]
  453. // CHECK:STDOUT: %.loc14_11.1: %tuple.type = tuple_literal (%C.ref.loc14_7, %C.ref.loc14_10)
  454. // CHECK:STDOUT: %.loc14_13: Core.IntLiteral = int_value 0 [template = constants.%.2]
  455. // CHECK:STDOUT: %tuple: %tuple.type = tuple_value (%C.ref.loc14_7, %C.ref.loc14_10) [template = constants.%tuple]
  456. // CHECK:STDOUT: %.loc14_11.2: %tuple.type = converted %.loc14_11.1, %tuple [template = constants.%tuple]
  457. // CHECK:STDOUT: %.loc14_12: type = tuple_access %.loc14_11.2, element0 [template = constants.%C]
  458. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [template = constants.%I.type]
  459. // CHECK:STDOUT: }
  460. // CHECK:STDOUT: }
  461. // CHECK:STDOUT:
  462. // CHECK:STDOUT: interface @I {
  463. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  464. // CHECK:STDOUT:
  465. // CHECK:STDOUT: !members:
  466. // CHECK:STDOUT: .Self = %Self
  467. // CHECK:STDOUT: witness = ()
  468. // CHECK:STDOUT: }
  469. // CHECK:STDOUT:
  470. // CHECK:STDOUT: impl @impl.1: %C.ref as %I.ref {
  471. // CHECK:STDOUT: %.loc13: <witness> = interface_witness () [template = constants.%.1]
  472. // CHECK:STDOUT:
  473. // CHECK:STDOUT: !members:
  474. // CHECK:STDOUT: witness = %.loc13
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT:
  477. // CHECK:STDOUT: impl @impl.2: %.loc14_12 as %I.ref {
  478. // CHECK:STDOUT: %.loc14_20: <witness> = interface_witness () [template = constants.%.1]
  479. // CHECK:STDOUT:
  480. // CHECK:STDOUT: !members:
  481. // CHECK:STDOUT: witness = %.loc14_20
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: class @C;
  485. // CHECK:STDOUT: