generic_redeclaration.carbon 28 KB

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