eq.carbon 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706
  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/operators/overloaded/eq.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/operators/overloaded/eq.carbon
  10. // --- user.carbon
  11. package User;
  12. class C {};
  13. impl C as Core.Eq {
  14. fn Equal[self: C](other: C) -> bool;
  15. fn NotEqual[self: C](other: C) -> bool;
  16. }
  17. fn TestEqual(a: C, b: C) -> bool {
  18. return a == b;
  19. }
  20. fn TestNotEqual(a: C, b: C) -> bool {
  21. return a != b;
  22. }
  23. // --- fail_no_impl.carbon
  24. package FailNoImpl;
  25. class D {};
  26. fn TestEqual(a: D, b: D) -> bool {
  27. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+4]]:10: ERROR: Cannot access member of interface `Eq` in type `D` that does not implement that interface.
  28. // CHECK:STDERR: return a == b;
  29. // CHECK:STDERR: ^~~~~~
  30. // CHECK:STDERR:
  31. return a == b;
  32. }
  33. fn TestNotEqual(a: D, b: D) -> bool {
  34. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+4]]:10: ERROR: Cannot access member of interface `Eq` in type `D` that does not implement that interface.
  35. // CHECK:STDERR: return a != b;
  36. // CHECK:STDERR: ^~~~~~
  37. // CHECK:STDERR:
  38. return a != b;
  39. }
  40. // --- fail_no_impl_for_args.carbon
  41. package FailNoImplForArgs;
  42. class C {};
  43. class D {};
  44. impl C as Core.Eq {
  45. fn Equal[self: C](other: C) -> bool;
  46. fn NotEqual[self: C](other: C) -> bool;
  47. }
  48. fn TestRhsBad(a: C, b: D) -> bool {
  49. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE+10]]:10: ERROR: Cannot implicitly convert from `D` to `C`.
  50. // CHECK:STDERR: return a == b;
  51. // CHECK:STDERR: ^~~~~~
  52. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE+7]]:10: Type `D` does not implement interface `ImplicitAs`.
  53. // CHECK:STDERR: return a == b;
  54. // CHECK:STDERR: ^~~~~~
  55. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE-11]]:3: Initializing parameter 1 of function declared here.
  56. // CHECK:STDERR: fn Equal[self: C](other: C) -> bool;
  57. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  58. // CHECK:STDERR:
  59. return a == b;
  60. }
  61. fn TestLhsBad(a: D, b: C) -> bool {
  62. // CHECK:STDERR: fail_no_impl_for_args.carbon:[[@LINE+3]]:10: ERROR: Cannot access member of interface `Eq` in type `D` that does not implement that interface.
  63. // CHECK:STDERR: return a != b;
  64. // CHECK:STDERR: ^~~~~~
  65. return a != b;
  66. }
  67. // CHECK:STDOUT: --- user.carbon
  68. // CHECK:STDOUT:
  69. // CHECK:STDOUT: constants {
  70. // CHECK:STDOUT: %C: type = class_type @C [template]
  71. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  72. // CHECK:STDOUT: %.2: type = interface_type @Eq [template]
  73. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic]
  74. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  75. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  76. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  77. // CHECK:STDOUT: %Equal.type.1: type = fn_type @Equal.1 [template]
  78. // CHECK:STDOUT: %Equal.1: %Equal.type.1 = struct_value () [template]
  79. // CHECK:STDOUT: %NotEqual.type.1: type = fn_type @NotEqual.1 [template]
  80. // CHECK:STDOUT: %NotEqual.1: %NotEqual.type.1 = struct_value () [template]
  81. // CHECK:STDOUT: %Equal.type.2: type = fn_type @Equal.2 [template]
  82. // CHECK:STDOUT: %Equal.2: %Equal.type.2 = struct_value () [template]
  83. // CHECK:STDOUT: %NotEqual.type.2: type = fn_type @NotEqual.2 [template]
  84. // CHECK:STDOUT: %NotEqual.2: %NotEqual.type.2 = struct_value () [template]
  85. // CHECK:STDOUT: %.4: <witness> = interface_witness (%Equal.1, %NotEqual.1) [template]
  86. // CHECK:STDOUT: %TestEqual.type: type = fn_type @TestEqual [template]
  87. // CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [template]
  88. // CHECK:STDOUT: %.5: type = ptr_type %.1 [template]
  89. // CHECK:STDOUT: %.6: type = assoc_entity_type %.2, %Equal.type.2 [template]
  90. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template]
  91. // CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [template]
  92. // CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [template]
  93. // CHECK:STDOUT: %.8: type = assoc_entity_type %.2, %NotEqual.type.2 [template]
  94. // CHECK:STDOUT: %.9: %.8 = assoc_entity element1, imports.%import_ref.9 [template]
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: imports {
  98. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  99. // CHECK:STDOUT: .Eq = %import_ref.1
  100. // CHECK:STDOUT: .Bool = %import_ref.7
  101. // CHECK:STDOUT: import Core//prelude
  102. // CHECK:STDOUT: import Core//prelude/operators
  103. // CHECK:STDOUT: import Core//prelude/types
  104. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  105. // CHECK:STDOUT: import Core//prelude/operators/as
  106. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  107. // CHECK:STDOUT: import Core//prelude/operators/comparison
  108. // CHECK:STDOUT: import Core//prelude/types/bool
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%.2]
  111. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
  112. // CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+31, loaded [template = constants.%.7]
  113. // CHECK:STDOUT: %import_ref.4: %.8 = import_ref Core//prelude/operators/comparison, inst+52, loaded [template = constants.%.9]
  114. // CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+26, loaded [template = constants.%Equal.2]
  115. // CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+47, loaded [template = constants.%NotEqual.2]
  116. // CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  117. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+26, unloaded
  118. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+47, unloaded
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: file {
  122. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  123. // CHECK:STDOUT: .Core = imports.%Core
  124. // CHECK:STDOUT: .C = %C.decl
  125. // CHECK:STDOUT: .TestEqual = %TestEqual.decl
  126. // CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl
  127. // CHECK:STDOUT: }
  128. // CHECK:STDOUT: %Core.import = import Core
  129. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  130. // CHECK:STDOUT: impl_decl @impl {
  131. // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
  132. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  133. // CHECK:STDOUT: %Eq.ref: type = name_ref Eq, imports.%import_ref.1 [template = constants.%.2]
  134. // CHECK:STDOUT: }
  135. // CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [template = constants.%TestEqual] {
  136. // CHECK:STDOUT: %C.ref.loc11_17: type = name_ref C, %C.decl [template = constants.%C]
  137. // CHECK:STDOUT: %a.loc11_14.1: %C = param a
  138. // CHECK:STDOUT: @TestEqual.%a: %C = bind_name a, %a.loc11_14.1
  139. // CHECK:STDOUT: %C.ref.loc11_23: type = name_ref C, %C.decl [template = constants.%C]
  140. // CHECK:STDOUT: %b.loc11_20.1: %C = param b
  141. // CHECK:STDOUT: @TestEqual.%b: %C = bind_name b, %b.loc11_20.1
  142. // CHECK:STDOUT: %bool.make_type.loc11: init type = call constants.%Bool() [template = bool]
  143. // CHECK:STDOUT: %.loc11_29.1: type = value_of_initializer %bool.make_type.loc11 [template = bool]
  144. // CHECK:STDOUT: %.loc11_29.2: type = converted %bool.make_type.loc11, %.loc11_29.1 [template = bool]
  145. // CHECK:STDOUT: @TestEqual.%return: ref bool = var <return slot>
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [template = constants.%TestNotEqual] {
  148. // CHECK:STDOUT: %C.ref.loc15_20: type = name_ref C, %C.decl [template = constants.%C]
  149. // CHECK:STDOUT: %a.loc15_17.1: %C = param a
  150. // CHECK:STDOUT: @TestNotEqual.%a: %C = bind_name a, %a.loc15_17.1
  151. // CHECK:STDOUT: %C.ref.loc15_26: type = name_ref C, %C.decl [template = constants.%C]
  152. // CHECK:STDOUT: %b.loc15_23.1: %C = param b
  153. // CHECK:STDOUT: @TestNotEqual.%b: %C = bind_name b, %b.loc15_23.1
  154. // CHECK:STDOUT: %bool.make_type.loc15: init type = call constants.%Bool() [template = bool]
  155. // CHECK:STDOUT: %.loc15_32.1: type = value_of_initializer %bool.make_type.loc15 [template = bool]
  156. // CHECK:STDOUT: %.loc15_32.2: type = converted %bool.make_type.loc15, %.loc15_32.1 [template = bool]
  157. // CHECK:STDOUT: @TestNotEqual.%return: ref bool = var <return slot>
  158. // CHECK:STDOUT: }
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: interface @Eq {
  162. // CHECK:STDOUT: !members:
  163. // CHECK:STDOUT: .Self = imports.%import_ref.2
  164. // CHECK:STDOUT: .Equal = imports.%import_ref.3
  165. // CHECK:STDOUT: .NotEqual = imports.%import_ref.4
  166. // CHECK:STDOUT: witness = (imports.%import_ref.5, imports.%import_ref.6)
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT:
  169. // CHECK:STDOUT: impl @impl: %C as %.2 {
  170. // CHECK:STDOUT: %Equal.decl: %Equal.type.1 = fn_decl @Equal.1 [template = constants.%Equal.1] {
  171. // CHECK:STDOUT: %C.ref.loc7_18: type = name_ref C, file.%C.decl [template = constants.%C]
  172. // CHECK:STDOUT: %self.loc7_12.1: %C = param self
  173. // CHECK:STDOUT: %self.loc7_12.2: %C = bind_name self, %self.loc7_12.1
  174. // CHECK:STDOUT: %C.ref.loc7_28: type = name_ref C, file.%C.decl [template = constants.%C]
  175. // CHECK:STDOUT: %other.loc7_21.1: %C = param other
  176. // CHECK:STDOUT: %other.loc7_21.2: %C = bind_name other, %other.loc7_21.1
  177. // CHECK:STDOUT: %bool.make_type.loc7: init type = call constants.%Bool() [template = bool]
  178. // CHECK:STDOUT: %.loc7_34.1: type = value_of_initializer %bool.make_type.loc7 [template = bool]
  179. // CHECK:STDOUT: %.loc7_34.2: type = converted %bool.make_type.loc7, %.loc7_34.1 [template = bool]
  180. // CHECK:STDOUT: %return.var.loc7: ref bool = var <return slot>
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT: %NotEqual.decl: %NotEqual.type.1 = fn_decl @NotEqual.1 [template = constants.%NotEqual.1] {
  183. // CHECK:STDOUT: %C.ref.loc8_21: type = name_ref C, file.%C.decl [template = constants.%C]
  184. // CHECK:STDOUT: %self.loc8_15.1: %C = param self
  185. // CHECK:STDOUT: %self.loc8_15.2: %C = bind_name self, %self.loc8_15.1
  186. // CHECK:STDOUT: %C.ref.loc8_31: type = name_ref C, file.%C.decl [template = constants.%C]
  187. // CHECK:STDOUT: %other.loc8_24.1: %C = param other
  188. // CHECK:STDOUT: %other.loc8_24.2: %C = bind_name other, %other.loc8_24.1
  189. // CHECK:STDOUT: %bool.make_type.loc8: init type = call constants.%Bool() [template = bool]
  190. // CHECK:STDOUT: %.loc8_37.1: type = value_of_initializer %bool.make_type.loc8 [template = bool]
  191. // CHECK:STDOUT: %.loc8_37.2: type = converted %bool.make_type.loc8, %.loc8_37.1 [template = bool]
  192. // CHECK:STDOUT: %return.var.loc8: ref bool = var <return slot>
  193. // CHECK:STDOUT: }
  194. // CHECK:STDOUT: %.loc6: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: !members:
  197. // CHECK:STDOUT: .Equal = %Equal.decl
  198. // CHECK:STDOUT: .NotEqual = %NotEqual.decl
  199. // CHECK:STDOUT: witness = %.loc6
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT:
  202. // CHECK:STDOUT: class @C {
  203. // CHECK:STDOUT: !members:
  204. // CHECK:STDOUT: .Self = constants.%C
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  208. // CHECK:STDOUT:
  209. // CHECK:STDOUT: fn @Equal.1[@impl.%self.loc7_12.2: %C](@impl.%other.loc7_21.2: %C) -> bool;
  210. // CHECK:STDOUT:
  211. // CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc8_15.2: %C](@impl.%other.loc8_24.2: %C) -> bool;
  212. // CHECK:STDOUT:
  213. // CHECK:STDOUT: generic fn @Equal.2(constants.%Self: %.2) {
  214. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)]
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: fn[%self: @Equal.2.%Self (%Self)](%other: @Equal.2.%Self (%Self)) -> bool;
  217. // CHECK:STDOUT: }
  218. // CHECK:STDOUT:
  219. // CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self: %.2) {
  220. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)]
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: fn[%self: @NotEqual.2.%Self (%Self)](%other: @NotEqual.2.%Self (%Self)) -> bool;
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: fn @TestEqual(%a: %C, %b: %C) -> bool {
  226. // CHECK:STDOUT: !entry:
  227. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  228. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  229. // CHECK:STDOUT: %Equal.ref: %.6 = name_ref Equal, imports.%import_ref.3 [template = constants.%.7]
  230. // CHECK:STDOUT: %.loc12_12.1: %Equal.type.2 = interface_witness_access @impl.%.loc6, element0 [template = constants.%Equal.1]
  231. // CHECK:STDOUT: %.loc12_12.2: <bound method> = bound_method %a.ref, %.loc12_12.1
  232. // CHECK:STDOUT: %Equal.call: init bool = call %.loc12_12.2(%a.ref, %b.ref)
  233. // CHECK:STDOUT: %.loc12_16.1: bool = value_of_initializer %Equal.call
  234. // CHECK:STDOUT: %.loc12_16.2: bool = converted %Equal.call, %.loc12_16.1
  235. // CHECK:STDOUT: return %.loc12_16.2
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: fn @TestNotEqual(%a: %C, %b: %C) -> bool {
  239. // CHECK:STDOUT: !entry:
  240. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  241. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  242. // CHECK:STDOUT: %NotEqual.ref: %.8 = name_ref NotEqual, imports.%import_ref.4 [template = constants.%.9]
  243. // CHECK:STDOUT: %.loc16_12.1: %NotEqual.type.2 = interface_witness_access @impl.%.loc6, element1 [template = constants.%NotEqual.1]
  244. // CHECK:STDOUT: %.loc16_12.2: <bound method> = bound_method %a.ref, %.loc16_12.1
  245. // CHECK:STDOUT: %NotEqual.call: init bool = call %.loc16_12.2(%a.ref, %b.ref)
  246. // CHECK:STDOUT: %.loc16_16.1: bool = value_of_initializer %NotEqual.call
  247. // CHECK:STDOUT: %.loc16_16.2: bool = converted %NotEqual.call, %.loc16_16.1
  248. // CHECK:STDOUT: return %.loc16_16.2
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: specific @Equal.2(constants.%Self) {
  252. // CHECK:STDOUT: %Self => constants.%Self
  253. // CHECK:STDOUT: }
  254. // CHECK:STDOUT:
  255. // CHECK:STDOUT: specific @Equal.2(constants.%C) {
  256. // CHECK:STDOUT: %Self => constants.%C
  257. // CHECK:STDOUT: }
  258. // CHECK:STDOUT:
  259. // CHECK:STDOUT: specific @NotEqual.2(constants.%Self) {
  260. // CHECK:STDOUT: %Self => constants.%Self
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: specific @NotEqual.2(constants.%C) {
  264. // CHECK:STDOUT: %Self => constants.%C
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: --- fail_no_impl.carbon
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: constants {
  270. // CHECK:STDOUT: %D: type = class_type @D [template]
  271. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  272. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  273. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  274. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  275. // CHECK:STDOUT: %TestEqual.type: type = fn_type @TestEqual [template]
  276. // CHECK:STDOUT: %TestEqual: %TestEqual.type = struct_value () [template]
  277. // CHECK:STDOUT: %.3: type = ptr_type %.1 [template]
  278. // CHECK:STDOUT: %.4: type = interface_type @Eq [template]
  279. // CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic]
  280. // CHECK:STDOUT: %Equal.type: type = fn_type @Equal [template]
  281. // CHECK:STDOUT: %Equal: %Equal.type = struct_value () [template]
  282. // CHECK:STDOUT: %.5: type = assoc_entity_type %.4, %Equal.type [template]
  283. // CHECK:STDOUT: %.6: %.5 = assoc_entity element0, imports.%import_ref.8 [template]
  284. // CHECK:STDOUT: %TestNotEqual.type: type = fn_type @TestNotEqual [template]
  285. // CHECK:STDOUT: %TestNotEqual: %TestNotEqual.type = struct_value () [template]
  286. // CHECK:STDOUT: %NotEqual.type: type = fn_type @NotEqual [template]
  287. // CHECK:STDOUT: %NotEqual: %NotEqual.type = struct_value () [template]
  288. // CHECK:STDOUT: %.7: type = assoc_entity_type %.4, %NotEqual.type [template]
  289. // CHECK:STDOUT: %.8: %.7 = assoc_entity element1, imports.%import_ref.9 [template]
  290. // CHECK:STDOUT: }
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: imports {
  293. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  294. // CHECK:STDOUT: .Bool = %import_ref.1
  295. // CHECK:STDOUT: .Eq = %import_ref.2
  296. // CHECK:STDOUT: import Core//prelude
  297. // CHECK:STDOUT: import Core//prelude/operators
  298. // CHECK:STDOUT: import Core//prelude/types
  299. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  300. // CHECK:STDOUT: import Core//prelude/operators/as
  301. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  302. // CHECK:STDOUT: import Core//prelude/operators/comparison
  303. // CHECK:STDOUT: import Core//prelude/types/bool
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT: %import_ref.1: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  306. // CHECK:STDOUT: %import_ref.2: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%.4]
  307. // CHECK:STDOUT: %import_ref.3 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
  308. // CHECK:STDOUT: %import_ref.4: %.5 = import_ref Core//prelude/operators/comparison, inst+31, loaded [template = constants.%.6]
  309. // CHECK:STDOUT: %import_ref.5: %.7 = import_ref Core//prelude/operators/comparison, inst+52, loaded [template = constants.%.8]
  310. // CHECK:STDOUT: %import_ref.6 = import_ref Core//prelude/operators/comparison, inst+26, unloaded
  311. // CHECK:STDOUT: %import_ref.7 = import_ref Core//prelude/operators/comparison, inst+47, unloaded
  312. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+26, unloaded
  313. // CHECK:STDOUT: %import_ref.9 = import_ref Core//prelude/operators/comparison, inst+47, unloaded
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: file {
  317. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  318. // CHECK:STDOUT: .Core = imports.%Core
  319. // CHECK:STDOUT: .D = %D.decl
  320. // CHECK:STDOUT: .TestEqual = %TestEqual.decl
  321. // CHECK:STDOUT: .TestNotEqual = %TestNotEqual.decl
  322. // CHECK:STDOUT: }
  323. // CHECK:STDOUT: %Core.import = import Core
  324. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {}
  325. // CHECK:STDOUT: %TestEqual.decl: %TestEqual.type = fn_decl @TestEqual [template = constants.%TestEqual] {
  326. // CHECK:STDOUT: %D.ref.loc6_17: type = name_ref D, %D.decl [template = constants.%D]
  327. // CHECK:STDOUT: %a.loc6_14.1: %D = param a
  328. // CHECK:STDOUT: @TestEqual.%a: %D = bind_name a, %a.loc6_14.1
  329. // CHECK:STDOUT: %D.ref.loc6_23: type = name_ref D, %D.decl [template = constants.%D]
  330. // CHECK:STDOUT: %b.loc6_20.1: %D = param b
  331. // CHECK:STDOUT: @TestEqual.%b: %D = bind_name b, %b.loc6_20.1
  332. // CHECK:STDOUT: %bool.make_type.loc6: init type = call constants.%Bool() [template = bool]
  333. // CHECK:STDOUT: %.loc6_29.1: type = value_of_initializer %bool.make_type.loc6 [template = bool]
  334. // CHECK:STDOUT: %.loc6_29.2: type = converted %bool.make_type.loc6, %.loc6_29.1 [template = bool]
  335. // CHECK:STDOUT: @TestEqual.%return: ref bool = var <return slot>
  336. // CHECK:STDOUT: }
  337. // CHECK:STDOUT: %TestNotEqual.decl: %TestNotEqual.type = fn_decl @TestNotEqual [template = constants.%TestNotEqual] {
  338. // CHECK:STDOUT: %D.ref.loc14_20: type = name_ref D, %D.decl [template = constants.%D]
  339. // CHECK:STDOUT: %a.loc14_17.1: %D = param a
  340. // CHECK:STDOUT: @TestNotEqual.%a: %D = bind_name a, %a.loc14_17.1
  341. // CHECK:STDOUT: %D.ref.loc14_26: type = name_ref D, %D.decl [template = constants.%D]
  342. // CHECK:STDOUT: %b.loc14_23.1: %D = param b
  343. // CHECK:STDOUT: @TestNotEqual.%b: %D = bind_name b, %b.loc14_23.1
  344. // CHECK:STDOUT: %bool.make_type.loc14: init type = call constants.%Bool() [template = bool]
  345. // CHECK:STDOUT: %.loc14_32.1: type = value_of_initializer %bool.make_type.loc14 [template = bool]
  346. // CHECK:STDOUT: %.loc14_32.2: type = converted %bool.make_type.loc14, %.loc14_32.1 [template = bool]
  347. // CHECK:STDOUT: @TestNotEqual.%return: ref bool = var <return slot>
  348. // CHECK:STDOUT: }
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: interface @Eq {
  352. // CHECK:STDOUT: !members:
  353. // CHECK:STDOUT: .Self = imports.%import_ref.3
  354. // CHECK:STDOUT: .Equal = imports.%import_ref.4
  355. // CHECK:STDOUT: .NotEqual = imports.%import_ref.5
  356. // CHECK:STDOUT: witness = (imports.%import_ref.6, imports.%import_ref.7)
  357. // CHECK:STDOUT: }
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: class @D {
  360. // CHECK:STDOUT: !members:
  361. // CHECK:STDOUT: .Self = constants.%D
  362. // CHECK:STDOUT: }
  363. // CHECK:STDOUT:
  364. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: fn @TestEqual(%a: %D, %b: %D) -> bool {
  367. // CHECK:STDOUT: !entry:
  368. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  369. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  370. // CHECK:STDOUT: %Equal.ref: %.5 = name_ref Equal, imports.%import_ref.4 [template = constants.%.6]
  371. // CHECK:STDOUT: return <error>
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT:
  374. // CHECK:STDOUT: generic fn @Equal(constants.%Self: %.4) {
  375. // CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)]
  376. // CHECK:STDOUT:
  377. // CHECK:STDOUT: fn[%self: @Equal.%Self (%Self)](%other: @Equal.%Self (%Self)) -> bool;
  378. // CHECK:STDOUT: }
  379. // CHECK:STDOUT:
  380. // CHECK:STDOUT: fn @TestNotEqual(%a: %D, %b: %D) -> bool {
  381. // CHECK:STDOUT: !entry:
  382. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  383. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  384. // CHECK:STDOUT: %NotEqual.ref: %.7 = name_ref NotEqual, imports.%import_ref.5 [template = constants.%.8]
  385. // CHECK:STDOUT: return <error>
  386. // CHECK:STDOUT: }
  387. // CHECK:STDOUT:
  388. // CHECK:STDOUT: generic fn @NotEqual(constants.%Self: %.4) {
  389. // CHECK:STDOUT: %Self: %.4 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self)]
  390. // CHECK:STDOUT:
  391. // CHECK:STDOUT: fn[%self: @NotEqual.%Self (%Self)](%other: @NotEqual.%Self (%Self)) -> bool;
  392. // CHECK:STDOUT: }
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: specific @Equal(constants.%Self) {
  395. // CHECK:STDOUT: %Self => constants.%Self
  396. // CHECK:STDOUT: }
  397. // CHECK:STDOUT:
  398. // CHECK:STDOUT: specific @NotEqual(constants.%Self) {
  399. // CHECK:STDOUT: %Self => constants.%Self
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT:
  402. // CHECK:STDOUT: --- fail_no_impl_for_args.carbon
  403. // CHECK:STDOUT:
  404. // CHECK:STDOUT: constants {
  405. // CHECK:STDOUT: %C: type = class_type @C [template]
  406. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  407. // CHECK:STDOUT: %D: type = class_type @D [template]
  408. // CHECK:STDOUT: %.2: type = interface_type @Eq [template]
  409. // CHECK:STDOUT: %Self.1: %.2 = bind_symbolic_name Self 0 [symbolic]
  410. // CHECK:STDOUT: %Bool.type: type = fn_type @Bool [template]
  411. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  412. // CHECK:STDOUT: %Bool: %Bool.type = struct_value () [template]
  413. // CHECK:STDOUT: %Equal.type.1: type = fn_type @Equal.1 [template]
  414. // CHECK:STDOUT: %Equal.1: %Equal.type.1 = struct_value () [template]
  415. // CHECK:STDOUT: %NotEqual.type.1: type = fn_type @NotEqual.1 [template]
  416. // CHECK:STDOUT: %NotEqual.1: %NotEqual.type.1 = struct_value () [template]
  417. // CHECK:STDOUT: %Equal.type.2: type = fn_type @Equal.2 [template]
  418. // CHECK:STDOUT: %Equal.2: %Equal.type.2 = struct_value () [template]
  419. // CHECK:STDOUT: %NotEqual.type.2: type = fn_type @NotEqual.2 [template]
  420. // CHECK:STDOUT: %NotEqual.2: %NotEqual.type.2 = struct_value () [template]
  421. // CHECK:STDOUT: %.4: <witness> = interface_witness (%Equal.1, %NotEqual.1) [template]
  422. // CHECK:STDOUT: %TestRhsBad.type: type = fn_type @TestRhsBad [template]
  423. // CHECK:STDOUT: %TestRhsBad: %TestRhsBad.type = struct_value () [template]
  424. // CHECK:STDOUT: %.5: type = ptr_type %.1 [template]
  425. // CHECK:STDOUT: %.6: type = assoc_entity_type %.2, %Equal.type.2 [template]
  426. // CHECK:STDOUT: %.7: %.6 = assoc_entity element0, imports.%import_ref.8 [template]
  427. // CHECK:STDOUT: %ImplicitAs.type: type = generic_interface_type @ImplicitAs [template]
  428. // CHECK:STDOUT: %ImplicitAs: %ImplicitAs.type = struct_value () [template]
  429. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic]
  430. // CHECK:STDOUT: %.8: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  431. // CHECK:STDOUT: %Self.2: @ImplicitAs.%.1 (%.8) = bind_symbolic_name Self 1 [symbolic]
  432. // CHECK:STDOUT: %Self.3: %.8 = bind_symbolic_name Self 1 [symbolic]
  433. // CHECK:STDOUT: %Convert.type.1: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  434. // CHECK:STDOUT: %Convert.1: %Convert.type.1 = struct_value () [symbolic]
  435. // CHECK:STDOUT: %.9: type = assoc_entity_type %.8, %Convert.type.1 [symbolic]
  436. // CHECK:STDOUT: %.10: %.9 = assoc_entity element0, imports.%import_ref.13 [symbolic]
  437. // CHECK:STDOUT: %.11: type = interface_type @ImplicitAs, @ImplicitAs(%C) [template]
  438. // CHECK:STDOUT: %Convert.type.2: type = fn_type @Convert, @ImplicitAs(%C) [template]
  439. // CHECK:STDOUT: %Convert.2: %Convert.type.2 = struct_value () [template]
  440. // CHECK:STDOUT: %.12: type = assoc_entity_type %.11, %Convert.type.2 [template]
  441. // CHECK:STDOUT: %.13: %.12 = assoc_entity element0, imports.%import_ref.13 [template]
  442. // CHECK:STDOUT: %.14: %.9 = assoc_entity element0, imports.%import_ref.14 [symbolic]
  443. // CHECK:STDOUT: %TestLhsBad.type: type = fn_type @TestLhsBad [template]
  444. // CHECK:STDOUT: %TestLhsBad: %TestLhsBad.type = struct_value () [template]
  445. // CHECK:STDOUT: %.15: type = assoc_entity_type %.2, %NotEqual.type.2 [template]
  446. // CHECK:STDOUT: %.16: %.15 = assoc_entity element1, imports.%import_ref.15 [template]
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: imports {
  450. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  451. // CHECK:STDOUT: .Eq = %import_ref.1
  452. // CHECK:STDOUT: .Bool = %import_ref.7
  453. // CHECK:STDOUT: .ImplicitAs = %import_ref.9
  454. // CHECK:STDOUT: import Core//prelude
  455. // CHECK:STDOUT: import Core//prelude/operators
  456. // CHECK:STDOUT: import Core//prelude/types
  457. // CHECK:STDOUT: import Core//prelude/operators/arithmetic
  458. // CHECK:STDOUT: import Core//prelude/operators/as
  459. // CHECK:STDOUT: import Core//prelude/operators/bitwise
  460. // CHECK:STDOUT: import Core//prelude/operators/comparison
  461. // CHECK:STDOUT: import Core//prelude/types/bool
  462. // CHECK:STDOUT: }
  463. // CHECK:STDOUT: %import_ref.1: type = import_ref Core//prelude/operators/comparison, inst+3, loaded [template = constants.%.2]
  464. // CHECK:STDOUT: %import_ref.2 = import_ref Core//prelude/operators/comparison, inst+5, unloaded
  465. // CHECK:STDOUT: %import_ref.3: %.6 = import_ref Core//prelude/operators/comparison, inst+31, loaded [template = constants.%.7]
  466. // CHECK:STDOUT: %import_ref.4: %.15 = import_ref Core//prelude/operators/comparison, inst+52, loaded [template = constants.%.16]
  467. // CHECK:STDOUT: %import_ref.5: %Equal.type.2 = import_ref Core//prelude/operators/comparison, inst+26, loaded [template = constants.%Equal.2]
  468. // CHECK:STDOUT: %import_ref.6: %NotEqual.type.2 = import_ref Core//prelude/operators/comparison, inst+47, loaded [template = constants.%NotEqual.2]
  469. // CHECK:STDOUT: %import_ref.7: %Bool.type = import_ref Core//prelude/types/bool, inst+2, loaded [template = constants.%Bool]
  470. // CHECK:STDOUT: %import_ref.8 = import_ref Core//prelude/operators/comparison, inst+26, unloaded
  471. // CHECK:STDOUT: %import_ref.9: %ImplicitAs.type = import_ref Core//prelude/operators/as, inst+37, loaded [template = constants.%ImplicitAs]
  472. // CHECK:STDOUT: %import_ref.10 = import_ref Core//prelude/operators/as, inst+42, unloaded
  473. // CHECK:STDOUT: %import_ref.11: @ImplicitAs.%.2 (%.9) = import_ref Core//prelude/operators/as, inst+59, loaded [symbolic = @ImplicitAs.%.3 (constants.%.14)]
  474. // CHECK:STDOUT: %import_ref.12 = import_ref Core//prelude/operators/as, inst+52, unloaded
  475. // CHECK:STDOUT: %import_ref.13 = import_ref Core//prelude/operators/as, inst+52, unloaded
  476. // CHECK:STDOUT: %import_ref.14 = import_ref Core//prelude/operators/as, inst+52, unloaded
  477. // CHECK:STDOUT: %import_ref.15 = import_ref Core//prelude/operators/comparison, inst+47, unloaded
  478. // CHECK:STDOUT: }
  479. // CHECK:STDOUT:
  480. // CHECK:STDOUT: file {
  481. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  482. // CHECK:STDOUT: .Core = imports.%Core
  483. // CHECK:STDOUT: .C = %C.decl
  484. // CHECK:STDOUT: .D = %D.decl
  485. // CHECK:STDOUT: .TestRhsBad = %TestRhsBad.decl
  486. // CHECK:STDOUT: .TestLhsBad = %TestLhsBad.decl
  487. // CHECK:STDOUT: }
  488. // CHECK:STDOUT: %Core.import = import Core
  489. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  490. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {}
  491. // CHECK:STDOUT: impl_decl @impl {
  492. // CHECK:STDOUT: %C.ref.loc7: type = name_ref C, %C.decl [template = constants.%C]
  493. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [template = imports.%Core]
  494. // CHECK:STDOUT: %Eq.ref: type = name_ref Eq, imports.%import_ref.1 [template = constants.%.2]
  495. // CHECK:STDOUT: }
  496. // CHECK:STDOUT: %TestRhsBad.decl: %TestRhsBad.type = fn_decl @TestRhsBad [template = constants.%TestRhsBad] {
  497. // CHECK:STDOUT: %C.ref.loc12: type = name_ref C, %C.decl [template = constants.%C]
  498. // CHECK:STDOUT: %a.loc12_15.1: %C = param a
  499. // CHECK:STDOUT: @TestRhsBad.%a: %C = bind_name a, %a.loc12_15.1
  500. // CHECK:STDOUT: %D.ref.loc12: type = name_ref D, %D.decl [template = constants.%D]
  501. // CHECK:STDOUT: %b.loc12_21.1: %D = param b
  502. // CHECK:STDOUT: @TestRhsBad.%b: %D = bind_name b, %b.loc12_21.1
  503. // CHECK:STDOUT: %bool.make_type.loc12: init type = call constants.%Bool() [template = bool]
  504. // CHECK:STDOUT: %.loc12_30.1: type = value_of_initializer %bool.make_type.loc12 [template = bool]
  505. // CHECK:STDOUT: %.loc12_30.2: type = converted %bool.make_type.loc12, %.loc12_30.1 [template = bool]
  506. // CHECK:STDOUT: @TestRhsBad.%return: ref bool = var <return slot>
  507. // CHECK:STDOUT: }
  508. // CHECK:STDOUT: %TestLhsBad.decl: %TestLhsBad.type = fn_decl @TestLhsBad [template = constants.%TestLhsBad] {
  509. // CHECK:STDOUT: %D.ref.loc26: type = name_ref D, %D.decl [template = constants.%D]
  510. // CHECK:STDOUT: %a.loc26_15.1: %D = param a
  511. // CHECK:STDOUT: @TestLhsBad.%a: %D = bind_name a, %a.loc26_15.1
  512. // CHECK:STDOUT: %C.ref.loc26: type = name_ref C, %C.decl [template = constants.%C]
  513. // CHECK:STDOUT: %b.loc26_21.1: %C = param b
  514. // CHECK:STDOUT: @TestLhsBad.%b: %C = bind_name b, %b.loc26_21.1
  515. // CHECK:STDOUT: %bool.make_type.loc26: init type = call constants.%Bool() [template = bool]
  516. // CHECK:STDOUT: %.loc26_30.1: type = value_of_initializer %bool.make_type.loc26 [template = bool]
  517. // CHECK:STDOUT: %.loc26_30.2: type = converted %bool.make_type.loc26, %.loc26_30.1 [template = bool]
  518. // CHECK:STDOUT: @TestLhsBad.%return: ref bool = var <return slot>
  519. // CHECK:STDOUT: }
  520. // CHECK:STDOUT: }
  521. // CHECK:STDOUT:
  522. // CHECK:STDOUT: interface @Eq {
  523. // CHECK:STDOUT: !members:
  524. // CHECK:STDOUT: .Self = imports.%import_ref.2
  525. // CHECK:STDOUT: .Equal = imports.%import_ref.3
  526. // CHECK:STDOUT: .NotEqual = imports.%import_ref.4
  527. // CHECK:STDOUT: witness = (imports.%import_ref.5, imports.%import_ref.6)
  528. // CHECK:STDOUT: }
  529. // CHECK:STDOUT:
  530. // CHECK:STDOUT: generic interface @ImplicitAs(constants.%Dest: type) {
  531. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  532. // CHECK:STDOUT:
  533. // CHECK:STDOUT: !definition:
  534. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.8)]
  535. // CHECK:STDOUT: %Self: %.8 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.3)]
  536. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic = %Convert.type (constants.%Convert.type.1)]
  537. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type.1) = struct_value () [symbolic = %Convert (constants.%Convert.1)]
  538. // CHECK:STDOUT: %.2: type = assoc_entity_type @ImplicitAs.%.1 (%.8), @ImplicitAs.%Convert.type (%Convert.type.1) [symbolic = %.2 (constants.%.9)]
  539. // CHECK:STDOUT: %.3: @ImplicitAs.%.2 (%.9) = assoc_entity element0, imports.%import_ref.13 [symbolic = %.3 (constants.%.10)]
  540. // CHECK:STDOUT:
  541. // CHECK:STDOUT: interface {
  542. // CHECK:STDOUT: !members:
  543. // CHECK:STDOUT: .Self = imports.%import_ref.10
  544. // CHECK:STDOUT: .Convert = imports.%import_ref.11
  545. // CHECK:STDOUT: witness = (imports.%import_ref.12)
  546. // CHECK:STDOUT: }
  547. // CHECK:STDOUT: }
  548. // CHECK:STDOUT:
  549. // CHECK:STDOUT: impl @impl: %C as %.2 {
  550. // CHECK:STDOUT: %Equal.decl: %Equal.type.1 = fn_decl @Equal.1 [template = constants.%Equal.1] {
  551. // CHECK:STDOUT: %C.ref.loc8_18: type = name_ref C, file.%C.decl [template = constants.%C]
  552. // CHECK:STDOUT: %self.loc8_12.1: %C = param self
  553. // CHECK:STDOUT: %self.loc8_12.2: %C = bind_name self, %self.loc8_12.1
  554. // CHECK:STDOUT: %C.ref.loc8_28: type = name_ref C, file.%C.decl [template = constants.%C]
  555. // CHECK:STDOUT: %other.loc8_21.1: %C = param other
  556. // CHECK:STDOUT: %other.loc8_21.2: %C = bind_name other, %other.loc8_21.1
  557. // CHECK:STDOUT: %bool.make_type.loc8: init type = call constants.%Bool() [template = bool]
  558. // CHECK:STDOUT: %.loc8_34.1: type = value_of_initializer %bool.make_type.loc8 [template = bool]
  559. // CHECK:STDOUT: %.loc8_34.2: type = converted %bool.make_type.loc8, %.loc8_34.1 [template = bool]
  560. // CHECK:STDOUT: %return.var.loc8: ref bool = var <return slot>
  561. // CHECK:STDOUT: }
  562. // CHECK:STDOUT: %NotEqual.decl: %NotEqual.type.1 = fn_decl @NotEqual.1 [template = constants.%NotEqual.1] {
  563. // CHECK:STDOUT: %C.ref.loc9_21: type = name_ref C, file.%C.decl [template = constants.%C]
  564. // CHECK:STDOUT: %self.loc9_15.1: %C = param self
  565. // CHECK:STDOUT: %self.loc9_15.2: %C = bind_name self, %self.loc9_15.1
  566. // CHECK:STDOUT: %C.ref.loc9_31: type = name_ref C, file.%C.decl [template = constants.%C]
  567. // CHECK:STDOUT: %other.loc9_24.1: %C = param other
  568. // CHECK:STDOUT: %other.loc9_24.2: %C = bind_name other, %other.loc9_24.1
  569. // CHECK:STDOUT: %bool.make_type.loc9: init type = call constants.%Bool() [template = bool]
  570. // CHECK:STDOUT: %.loc9_37.1: type = value_of_initializer %bool.make_type.loc9 [template = bool]
  571. // CHECK:STDOUT: %.loc9_37.2: type = converted %bool.make_type.loc9, %.loc9_37.1 [template = bool]
  572. // CHECK:STDOUT: %return.var.loc9: ref bool = var <return slot>
  573. // CHECK:STDOUT: }
  574. // CHECK:STDOUT: %.loc7: <witness> = interface_witness (%Equal.decl, %NotEqual.decl) [template = constants.%.4]
  575. // CHECK:STDOUT:
  576. // CHECK:STDOUT: !members:
  577. // CHECK:STDOUT: .Equal = %Equal.decl
  578. // CHECK:STDOUT: .NotEqual = %NotEqual.decl
  579. // CHECK:STDOUT: witness = %.loc7
  580. // CHECK:STDOUT: }
  581. // CHECK:STDOUT:
  582. // CHECK:STDOUT: class @C {
  583. // CHECK:STDOUT: !members:
  584. // CHECK:STDOUT: .Self = constants.%C
  585. // CHECK:STDOUT: }
  586. // CHECK:STDOUT:
  587. // CHECK:STDOUT: class @D {
  588. // CHECK:STDOUT: !members:
  589. // CHECK:STDOUT: .Self = constants.%D
  590. // CHECK:STDOUT: }
  591. // CHECK:STDOUT:
  592. // CHECK:STDOUT: fn @Bool() -> type = "bool.make_type";
  593. // CHECK:STDOUT:
  594. // CHECK:STDOUT: fn @Equal.1[@impl.%self.loc8_12.2: %C](@impl.%other.loc8_21.2: %C) -> bool;
  595. // CHECK:STDOUT:
  596. // CHECK:STDOUT: fn @NotEqual.1[@impl.%self.loc9_15.2: %C](@impl.%other.loc9_24.2: %C) -> bool;
  597. // CHECK:STDOUT:
  598. // CHECK:STDOUT: generic fn @Equal.2(constants.%Self.1: %.2) {
  599. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)]
  600. // CHECK:STDOUT:
  601. // CHECK:STDOUT: fn[%self: @Equal.2.%Self (%Self.1)](%other: @Equal.2.%Self (%Self.1)) -> bool;
  602. // CHECK:STDOUT: }
  603. // CHECK:STDOUT:
  604. // CHECK:STDOUT: generic fn @NotEqual.2(constants.%Self.1: %.2) {
  605. // CHECK:STDOUT: %Self: %.2 = bind_symbolic_name Self 0 [symbolic = %Self (constants.%Self.1)]
  606. // CHECK:STDOUT:
  607. // CHECK:STDOUT: fn[%self: @NotEqual.2.%Self (%Self.1)](%other: @NotEqual.2.%Self (%Self.1)) -> bool;
  608. // CHECK:STDOUT: }
  609. // CHECK:STDOUT:
  610. // CHECK:STDOUT: fn @TestRhsBad(%a: %C, %b: %D) -> bool {
  611. // CHECK:STDOUT: !entry:
  612. // CHECK:STDOUT: %a.ref: %C = name_ref a, %a
  613. // CHECK:STDOUT: %b.ref: %D = name_ref b, %b
  614. // CHECK:STDOUT: %Equal.ref: %.6 = name_ref Equal, imports.%import_ref.3 [template = constants.%.7]
  615. // CHECK:STDOUT: %.loc23_12.1: %Equal.type.2 = interface_witness_access @impl.%.loc7, element0 [template = constants.%Equal.1]
  616. // CHECK:STDOUT: %.loc23_12.2: <bound method> = bound_method %a.ref, %.loc23_12.1
  617. // CHECK:STDOUT: %.loc23_12.3: init type = call constants.%ImplicitAs(constants.%C) [template = constants.%.11]
  618. // CHECK:STDOUT: %.loc23_12.4: %.12 = specific_constant imports.%import_ref.11, @ImplicitAs(constants.%C) [template = constants.%.13]
  619. // CHECK:STDOUT: %Convert.ref: %.12 = name_ref Convert, %.loc23_12.4 [template = constants.%.13]
  620. // CHECK:STDOUT: %.loc23_12.5: %C = converted %b.ref, <error> [template = <error>]
  621. // CHECK:STDOUT: %Equal.call: init bool = call %.loc23_12.2(<invalid>) [template = <error>]
  622. // CHECK:STDOUT: %.loc23_16.1: bool = value_of_initializer %Equal.call [template = <error>]
  623. // CHECK:STDOUT: %.loc23_16.2: bool = converted %Equal.call, %.loc23_16.1 [template = <error>]
  624. // CHECK:STDOUT: return %.loc23_16.2
  625. // CHECK:STDOUT: }
  626. // CHECK:STDOUT:
  627. // CHECK:STDOUT: generic fn @Convert(constants.%Dest: type, constants.%Self.2: @ImplicitAs.%.1 (%.8)) {
  628. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest 0 [symbolic = %Dest (constants.%Dest)]
  629. // CHECK:STDOUT: %.1: type = interface_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic = %.1 (constants.%.8)]
  630. // CHECK:STDOUT: %Self: %.8 = bind_symbolic_name Self 1 [symbolic = %Self (constants.%Self.3)]
  631. // CHECK:STDOUT:
  632. // CHECK:STDOUT: fn[%self: @Convert.%Self (%Self.3)]() -> @Convert.%Dest (%Dest);
  633. // CHECK:STDOUT: }
  634. // CHECK:STDOUT:
  635. // CHECK:STDOUT: fn @TestLhsBad(%a: %D, %b: %C) -> bool {
  636. // CHECK:STDOUT: !entry:
  637. // CHECK:STDOUT: %a.ref: %D = name_ref a, %a
  638. // CHECK:STDOUT: %b.ref: %C = name_ref b, %b
  639. // CHECK:STDOUT: %NotEqual.ref: %.15 = name_ref NotEqual, imports.%import_ref.4 [template = constants.%.16]
  640. // CHECK:STDOUT: return <error>
  641. // CHECK:STDOUT: }
  642. // CHECK:STDOUT:
  643. // CHECK:STDOUT: specific @Equal.2(constants.%Self.1) {
  644. // CHECK:STDOUT: %Self => constants.%Self.1
  645. // CHECK:STDOUT: }
  646. // CHECK:STDOUT:
  647. // CHECK:STDOUT: specific @Equal.2(constants.%C) {
  648. // CHECK:STDOUT: %Self => constants.%C
  649. // CHECK:STDOUT: }
  650. // CHECK:STDOUT:
  651. // CHECK:STDOUT: specific @NotEqual.2(constants.%Self.1) {
  652. // CHECK:STDOUT: %Self => constants.%Self.1
  653. // CHECK:STDOUT: }
  654. // CHECK:STDOUT:
  655. // CHECK:STDOUT: specific @NotEqual.2(constants.%C) {
  656. // CHECK:STDOUT: %Self => constants.%C
  657. // CHECK:STDOUT: }
  658. // CHECK:STDOUT:
  659. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  660. // CHECK:STDOUT: %Dest => constants.%Dest
  661. // CHECK:STDOUT: }
  662. // CHECK:STDOUT:
  663. // CHECK:STDOUT: specific @ImplicitAs(@ImplicitAs.%Dest) {
  664. // CHECK:STDOUT: %Dest => constants.%Dest
  665. // CHECK:STDOUT: }
  666. // CHECK:STDOUT:
  667. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {
  668. // CHECK:STDOUT: %Dest => constants.%Dest
  669. // CHECK:STDOUT: }
  670. // CHECK:STDOUT:
  671. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self.2) {
  672. // CHECK:STDOUT: %Dest => constants.%Dest
  673. // CHECK:STDOUT: %.1 => constants.%.8
  674. // CHECK:STDOUT: %Self => constants.%Self.2
  675. // CHECK:STDOUT: }
  676. // CHECK:STDOUT:
  677. // CHECK:STDOUT: specific @ImplicitAs(constants.%C) {
  678. // CHECK:STDOUT: %Dest => constants.%C
  679. // CHECK:STDOUT:
  680. // CHECK:STDOUT: !definition:
  681. // CHECK:STDOUT: %.1 => constants.%.11
  682. // CHECK:STDOUT: %Self => constants.%Self.3
  683. // CHECK:STDOUT: %Convert.type => constants.%Convert.type.2
  684. // CHECK:STDOUT: %Convert => constants.%Convert.2
  685. // CHECK:STDOUT: %.2 => constants.%.12
  686. // CHECK:STDOUT: %.3 => constants.%.13
  687. // CHECK:STDOUT: }
  688. // CHECK:STDOUT: