generic_redeclaration.carbon 29 KB

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