generic_redeclaration.carbon 29 KB

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