ordered.carbon 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  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. // --- user.carbon
  7. package User;
  8. class C {};
  9. impl C as Core.Ordered {
  10. fn Less[self: C](other: C) -> bool;
  11. fn LessOrEquivalent[self: C](other: C) -> bool;
  12. fn Greater[self: C](other: C) -> bool;
  13. fn GreaterOrEquivalent[self: C](other: C) -> bool;
  14. }
  15. fn TestLess(a: C, b: C) -> bool {
  16. return a < b;
  17. }
  18. fn TestLessEqual(a: C, b: C) -> bool {
  19. return a <= b;
  20. }
  21. fn TestGreater(a: C, b: C) -> bool {
  22. return a > b;
  23. }
  24. fn TestGreaterEqual(a: C, b: C) -> bool {
  25. return a >= b;
  26. }
  27. // --- fail_no_impl.carbon
  28. package FailNoImpl;
  29. class D {};
  30. fn TestLess(a: D, b: D) -> bool {
  31. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+4]]:10: ERROR: Cannot access member of interface Ordered in type D that does not implement that interface.
  32. // CHECK:STDERR: return a < b;
  33. // CHECK:STDERR: ^~~~~
  34. // CHECK:STDERR:
  35. return a < b;
  36. }
  37. fn TestLessEqual(a: D, b: D) -> bool {
  38. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+4]]:10: ERROR: Cannot access member of interface Ordered in type D that does not implement that interface.
  39. // CHECK:STDERR: return a <= b;
  40. // CHECK:STDERR: ^~~~~~
  41. // CHECK:STDERR:
  42. return a <= b;
  43. }
  44. fn TestGreater(a: D, b: D) -> bool {
  45. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+4]]:10: ERROR: Cannot access member of interface Ordered in type D that does not implement that interface.
  46. // CHECK:STDERR: return a > b;
  47. // CHECK:STDERR: ^~~~~
  48. // CHECK:STDERR:
  49. return a > b;
  50. }
  51. fn TestGreaterEqual(a: D, b: D) -> bool {
  52. // CHECK:STDERR: fail_no_impl.carbon:[[@LINE+3]]:10: ERROR: Cannot access member of interface Ordered in type D that does not implement that interface.
  53. // CHECK:STDERR: return a >= b;
  54. // CHECK:STDERR: ^~~~~~
  55. return a >= b;
  56. }
  57. // CHECK:STDOUT: --- user.carbon
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: constants {
  60. // CHECK:STDOUT: %C: type = class_type @C [template]
  61. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  62. // CHECK:STDOUT: %.2: type = interface_type @Ordered [template]
  63. // CHECK:STDOUT: %Self: Ordered = bind_symbolic_name Self 0 [symbolic]
  64. // CHECK:STDOUT: %Less.1: type = fn_type @Less.1 [template]
  65. // CHECK:STDOUT: %.3: type = tuple_type () [template]
  66. // CHECK:STDOUT: %struct.1: Less = struct_value () [template]
  67. // CHECK:STDOUT: %LessOrEquivalent.1: type = fn_type @LessOrEquivalent.1 [template]
  68. // CHECK:STDOUT: %struct.2: LessOrEquivalent = struct_value () [template]
  69. // CHECK:STDOUT: %Greater.1: type = fn_type @Greater.1 [template]
  70. // CHECK:STDOUT: %struct.3: Greater = struct_value () [template]
  71. // CHECK:STDOUT: %GreaterOrEquivalent.1: type = fn_type @GreaterOrEquivalent.1 [template]
  72. // CHECK:STDOUT: %struct.4: GreaterOrEquivalent = struct_value () [template]
  73. // CHECK:STDOUT: %Less.2: type = fn_type @Less.2 [template]
  74. // CHECK:STDOUT: %struct.5: Less = struct_value () [template]
  75. // CHECK:STDOUT: %LessOrEquivalent.2: type = fn_type @LessOrEquivalent.2 [template]
  76. // CHECK:STDOUT: %struct.6: LessOrEquivalent = struct_value () [template]
  77. // CHECK:STDOUT: %Greater.2: type = fn_type @Greater.2 [template]
  78. // CHECK:STDOUT: %struct.7: Greater = struct_value () [template]
  79. // CHECK:STDOUT: %GreaterOrEquivalent.2: type = fn_type @GreaterOrEquivalent.2 [template]
  80. // CHECK:STDOUT: %struct.8: GreaterOrEquivalent = struct_value () [template]
  81. // CHECK:STDOUT: %.4: <witness> = interface_witness (%struct.1, %struct.2, %struct.3, %struct.4) [template]
  82. // CHECK:STDOUT: %TestLess: type = fn_type @TestLess [template]
  83. // CHECK:STDOUT: %struct.9: TestLess = struct_value () [template]
  84. // CHECK:STDOUT: %.5: type = ptr_type {} [template]
  85. // CHECK:STDOUT: %.6: type = assoc_entity_type @Ordered, Less [template]
  86. // CHECK:STDOUT: %.7: <associated Less in Ordered> = assoc_entity element0, file.%import_ref.12 [template]
  87. // CHECK:STDOUT: %TestLessEqual: type = fn_type @TestLessEqual [template]
  88. // CHECK:STDOUT: %struct.10: TestLessEqual = struct_value () [template]
  89. // CHECK:STDOUT: %.8: type = assoc_entity_type @Ordered, LessOrEquivalent [template]
  90. // CHECK:STDOUT: %.9: <associated LessOrEquivalent in Ordered> = assoc_entity element1, file.%import_ref.14 [template]
  91. // CHECK:STDOUT: %TestGreater: type = fn_type @TestGreater [template]
  92. // CHECK:STDOUT: %struct.11: TestGreater = struct_value () [template]
  93. // CHECK:STDOUT: %.10: type = assoc_entity_type @Ordered, Greater [template]
  94. // CHECK:STDOUT: %.11: <associated Greater in Ordered> = assoc_entity element2, file.%import_ref.16 [template]
  95. // CHECK:STDOUT: %TestGreaterEqual: type = fn_type @TestGreaterEqual [template]
  96. // CHECK:STDOUT: %struct.12: TestGreaterEqual = struct_value () [template]
  97. // CHECK:STDOUT: %.12: type = assoc_entity_type @Ordered, GreaterOrEquivalent [template]
  98. // CHECK:STDOUT: %.13: <associated GreaterOrEquivalent in Ordered> = assoc_entity element3, file.%import_ref.18 [template]
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: file {
  102. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  103. // CHECK:STDOUT: .Core = %Core
  104. // CHECK:STDOUT: .C = %C.decl
  105. // CHECK:STDOUT: .TestLess = %TestLess.decl
  106. // CHECK:STDOUT: .TestLessEqual = %TestLessEqual.decl
  107. // CHECK:STDOUT: .TestGreater = %TestGreater.decl
  108. // CHECK:STDOUT: .TestGreaterEqual = %TestGreaterEqual.decl
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  111. // CHECK:STDOUT: %C.decl: type = class_decl @C [template = constants.%C] {}
  112. // CHECK:STDOUT: %import_ref.1: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
  113. // CHECK:STDOUT: %import_ref.2: <associated Less in Ordered> = import_ref ir6, inst+59, loaded [template = constants.%.7]
  114. // CHECK:STDOUT: %import_ref.3: <associated Greater in Ordered> = import_ref ir6, inst+93, loaded [template = constants.%.11]
  115. // CHECK:STDOUT: %import_ref.4 = import_ref ir6, inst+42, unloaded
  116. // CHECK:STDOUT: %import_ref.5: <associated LessOrEquivalent in Ordered> = import_ref ir6, inst+76, loaded [template = constants.%.9]
  117. // CHECK:STDOUT: %import_ref.6: <associated GreaterOrEquivalent in Ordered> = import_ref ir6, inst+110, loaded [template = constants.%.13]
  118. // CHECK:STDOUT: %import_ref.7: Less = import_ref ir6, inst+55, loaded [template = constants.%struct.5]
  119. // CHECK:STDOUT: %import_ref.8: LessOrEquivalent = import_ref ir6, inst+72, loaded [template = constants.%struct.6]
  120. // CHECK:STDOUT: %import_ref.9: Greater = import_ref ir6, inst+89, loaded [template = constants.%struct.7]
  121. // CHECK:STDOUT: %import_ref.10: GreaterOrEquivalent = import_ref ir6, inst+106, loaded [template = constants.%struct.8]
  122. // CHECK:STDOUT: impl_decl @impl {
  123. // CHECK:STDOUT: %C.ref.loc6: type = name_ref C, %C.decl [template = constants.%C]
  124. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, %Core [template = %Core]
  125. // CHECK:STDOUT: %Ordered.ref: type = name_ref Ordered, %import_ref.1 [template = constants.%.2]
  126. // CHECK:STDOUT: }
  127. // CHECK:STDOUT: %TestLess.decl: TestLess = fn_decl @TestLess [template = constants.%struct.9] {
  128. // CHECK:STDOUT: %C.ref.loc13_16: type = name_ref C, %C.decl [template = constants.%C]
  129. // CHECK:STDOUT: %a.loc13_13.1: C = param a
  130. // CHECK:STDOUT: @TestLess.%a: C = bind_name a, %a.loc13_13.1
  131. // CHECK:STDOUT: %C.ref.loc13_22: type = name_ref C, %C.decl [template = constants.%C]
  132. // CHECK:STDOUT: %b.loc13_19.1: C = param b
  133. // CHECK:STDOUT: @TestLess.%b: C = bind_name b, %b.loc13_19.1
  134. // CHECK:STDOUT: @TestLess.%return: ref bool = var <return slot>
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT: %import_ref.11: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
  137. // CHECK:STDOUT: %import_ref.12 = import_ref ir6, inst+55, unloaded
  138. // CHECK:STDOUT: %TestLessEqual.decl: TestLessEqual = fn_decl @TestLessEqual [template = constants.%struct.10] {
  139. // CHECK:STDOUT: %C.ref.loc17_21: type = name_ref C, %C.decl [template = constants.%C]
  140. // CHECK:STDOUT: %a.loc17_18.1: C = param a
  141. // CHECK:STDOUT: @TestLessEqual.%a: C = bind_name a, %a.loc17_18.1
  142. // CHECK:STDOUT: %C.ref.loc17_27: type = name_ref C, %C.decl [template = constants.%C]
  143. // CHECK:STDOUT: %b.loc17_24.1: C = param b
  144. // CHECK:STDOUT: @TestLessEqual.%b: C = bind_name b, %b.loc17_24.1
  145. // CHECK:STDOUT: @TestLessEqual.%return: ref bool = var <return slot>
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %import_ref.13: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
  148. // CHECK:STDOUT: %import_ref.14 = import_ref ir6, inst+72, unloaded
  149. // CHECK:STDOUT: %TestGreater.decl: TestGreater = fn_decl @TestGreater [template = constants.%struct.11] {
  150. // CHECK:STDOUT: %C.ref.loc21_19: type = name_ref C, %C.decl [template = constants.%C]
  151. // CHECK:STDOUT: %a.loc21_16.1: C = param a
  152. // CHECK:STDOUT: @TestGreater.%a: C = bind_name a, %a.loc21_16.1
  153. // CHECK:STDOUT: %C.ref.loc21_25: type = name_ref C, %C.decl [template = constants.%C]
  154. // CHECK:STDOUT: %b.loc21_22.1: C = param b
  155. // CHECK:STDOUT: @TestGreater.%b: C = bind_name b, %b.loc21_22.1
  156. // CHECK:STDOUT: @TestGreater.%return: ref bool = var <return slot>
  157. // CHECK:STDOUT: }
  158. // CHECK:STDOUT: %import_ref.15: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
  159. // CHECK:STDOUT: %import_ref.16 = import_ref ir6, inst+89, unloaded
  160. // CHECK:STDOUT: %TestGreaterEqual.decl: TestGreaterEqual = fn_decl @TestGreaterEqual [template = constants.%struct.12] {
  161. // CHECK:STDOUT: %C.ref.loc25_24: type = name_ref C, %C.decl [template = constants.%C]
  162. // CHECK:STDOUT: %a.loc25_21.1: C = param a
  163. // CHECK:STDOUT: @TestGreaterEqual.%a: C = bind_name a, %a.loc25_21.1
  164. // CHECK:STDOUT: %C.ref.loc25_30: type = name_ref C, %C.decl [template = constants.%C]
  165. // CHECK:STDOUT: %b.loc25_27.1: C = param b
  166. // CHECK:STDOUT: @TestGreaterEqual.%b: C = bind_name b, %b.loc25_27.1
  167. // CHECK:STDOUT: @TestGreaterEqual.%return: ref bool = var <return slot>
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT: %import_ref.17: type = import_ref ir6, inst+40, loaded [template = constants.%.2]
  170. // CHECK:STDOUT: %import_ref.18 = import_ref ir6, inst+106, unloaded
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: interface @Ordered {
  174. // CHECK:STDOUT: !members:
  175. // CHECK:STDOUT: .Less = file.%import_ref.2
  176. // CHECK:STDOUT: .Greater = file.%import_ref.3
  177. // CHECK:STDOUT: .Self = file.%import_ref.4
  178. // CHECK:STDOUT: .LessOrEquivalent = file.%import_ref.5
  179. // CHECK:STDOUT: .GreaterOrEquivalent = file.%import_ref.6
  180. // CHECK:STDOUT: witness = (file.%import_ref.7, file.%import_ref.8, file.%import_ref.9, file.%import_ref.10)
  181. // CHECK:STDOUT: }
  182. // CHECK:STDOUT:
  183. // CHECK:STDOUT: impl @impl: C as Ordered {
  184. // CHECK:STDOUT: %Less.decl: Less = fn_decl @Less.1 [template = constants.%struct.1] {
  185. // CHECK:STDOUT: %C.ref.loc7_17: type = name_ref C, file.%C.decl [template = constants.%C]
  186. // CHECK:STDOUT: %self.loc7_11.1: C = param self
  187. // CHECK:STDOUT: %self.loc7_11.2: C = bind_name self, %self.loc7_11.1
  188. // CHECK:STDOUT: %C.ref.loc7_27: type = name_ref C, file.%C.decl [template = constants.%C]
  189. // CHECK:STDOUT: %other.loc7_20.1: C = param other
  190. // CHECK:STDOUT: %other.loc7_20.2: C = bind_name other, %other.loc7_20.1
  191. // CHECK:STDOUT: %return.var.loc7: ref bool = var <return slot>
  192. // CHECK:STDOUT: }
  193. // CHECK:STDOUT: %LessOrEquivalent.decl: LessOrEquivalent = fn_decl @LessOrEquivalent.1 [template = constants.%struct.2] {
  194. // CHECK:STDOUT: %C.ref.loc8_29: type = name_ref C, file.%C.decl [template = constants.%C]
  195. // CHECK:STDOUT: %self.loc8_23.1: C = param self
  196. // CHECK:STDOUT: %self.loc8_23.2: C = bind_name self, %self.loc8_23.1
  197. // CHECK:STDOUT: %C.ref.loc8_39: type = name_ref C, file.%C.decl [template = constants.%C]
  198. // CHECK:STDOUT: %other.loc8_32.1: C = param other
  199. // CHECK:STDOUT: %other.loc8_32.2: C = bind_name other, %other.loc8_32.1
  200. // CHECK:STDOUT: %return.var.loc8: ref bool = var <return slot>
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: %Greater.decl: Greater = fn_decl @Greater.1 [template = constants.%struct.3] {
  203. // CHECK:STDOUT: %C.ref.loc9_20: type = name_ref C, file.%C.decl [template = constants.%C]
  204. // CHECK:STDOUT: %self.loc9_14.1: C = param self
  205. // CHECK:STDOUT: %self.loc9_14.2: C = bind_name self, %self.loc9_14.1
  206. // CHECK:STDOUT: %C.ref.loc9_30: type = name_ref C, file.%C.decl [template = constants.%C]
  207. // CHECK:STDOUT: %other.loc9_23.1: C = param other
  208. // CHECK:STDOUT: %other.loc9_23.2: C = bind_name other, %other.loc9_23.1
  209. // CHECK:STDOUT: %return.var.loc9: ref bool = var <return slot>
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT: %GreaterOrEquivalent.decl: GreaterOrEquivalent = fn_decl @GreaterOrEquivalent.1 [template = constants.%struct.4] {
  212. // CHECK:STDOUT: %C.ref.loc10_32: type = name_ref C, file.%C.decl [template = constants.%C]
  213. // CHECK:STDOUT: %self.loc10_26.1: C = param self
  214. // CHECK:STDOUT: %self.loc10_26.2: C = bind_name self, %self.loc10_26.1
  215. // CHECK:STDOUT: %C.ref.loc10_42: type = name_ref C, file.%C.decl [template = constants.%C]
  216. // CHECK:STDOUT: %other.loc10_35.1: C = param other
  217. // CHECK:STDOUT: %other.loc10_35.2: C = bind_name other, %other.loc10_35.1
  218. // CHECK:STDOUT: %return.var.loc10: ref bool = var <return slot>
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT: %.1: <witness> = interface_witness (%Less.decl, %LessOrEquivalent.decl, %Greater.decl, %GreaterOrEquivalent.decl) [template = constants.%.4]
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: !members:
  223. // CHECK:STDOUT: .Less = %Less.decl
  224. // CHECK:STDOUT: .LessOrEquivalent = %LessOrEquivalent.decl
  225. // CHECK:STDOUT: .Greater = %Greater.decl
  226. // CHECK:STDOUT: .GreaterOrEquivalent = %GreaterOrEquivalent.decl
  227. // CHECK:STDOUT: witness = %.1
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: class @C {
  231. // CHECK:STDOUT: !members:
  232. // CHECK:STDOUT: .Self = constants.%C
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: fn @Less.1[@impl.%self.loc7_11.2: C](@impl.%other.loc7_20.2: C) -> bool;
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: fn @LessOrEquivalent.1[@impl.%self.loc8_23.2: C](@impl.%other.loc8_32.2: C) -> bool;
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: fn @Greater.1[@impl.%self.loc9_14.2: C](@impl.%other.loc9_23.2: C) -> bool;
  240. // CHECK:STDOUT:
  241. // CHECK:STDOUT: fn @GreaterOrEquivalent.1[@impl.%self.loc10_26.2: C](@impl.%other.loc10_35.2: C) -> bool;
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: fn @Less.2[%self: Self](%other: Self) -> bool;
  244. // CHECK:STDOUT:
  245. // CHECK:STDOUT: fn @LessOrEquivalent.2[%self: Self](%other: Self) -> bool;
  246. // CHECK:STDOUT:
  247. // CHECK:STDOUT: fn @Greater.2[%self: Self](%other: Self) -> bool;
  248. // CHECK:STDOUT:
  249. // CHECK:STDOUT: fn @GreaterOrEquivalent.2[%self: Self](%other: Self) -> bool;
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: fn @TestLess(%a: C, %b: C) -> bool {
  252. // CHECK:STDOUT: !entry:
  253. // CHECK:STDOUT: %a.ref: C = name_ref a, %a
  254. // CHECK:STDOUT: %b.ref: C = name_ref b, %b
  255. // CHECK:STDOUT: %.1: Less = interface_witness_access @impl.%.1, element0 [template = constants.%struct.1]
  256. // CHECK:STDOUT: %.loc14_12: <bound method> = bound_method %a.ref, %.1
  257. // CHECK:STDOUT: %Less.call: init bool = call %.loc14_12(%a.ref, %b.ref)
  258. // CHECK:STDOUT: %.loc14_15.1: bool = value_of_initializer %Less.call
  259. // CHECK:STDOUT: %.loc14_15.2: bool = converted %Less.call, %.loc14_15.1
  260. // CHECK:STDOUT: return %.loc14_15.2
  261. // CHECK:STDOUT: }
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: fn @TestLessEqual(%a: C, %b: C) -> bool {
  264. // CHECK:STDOUT: !entry:
  265. // CHECK:STDOUT: %a.ref: C = name_ref a, %a
  266. // CHECK:STDOUT: %b.ref: C = name_ref b, %b
  267. // CHECK:STDOUT: %.1: LessOrEquivalent = interface_witness_access @impl.%.1, element1 [template = constants.%struct.2]
  268. // CHECK:STDOUT: %.loc18_12: <bound method> = bound_method %a.ref, %.1
  269. // CHECK:STDOUT: %LessOrEquivalent.call: init bool = call %.loc18_12(%a.ref, %b.ref)
  270. // CHECK:STDOUT: %.loc18_16.1: bool = value_of_initializer %LessOrEquivalent.call
  271. // CHECK:STDOUT: %.loc18_16.2: bool = converted %LessOrEquivalent.call, %.loc18_16.1
  272. // CHECK:STDOUT: return %.loc18_16.2
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: fn @TestGreater(%a: C, %b: C) -> bool {
  276. // CHECK:STDOUT: !entry:
  277. // CHECK:STDOUT: %a.ref: C = name_ref a, %a
  278. // CHECK:STDOUT: %b.ref: C = name_ref b, %b
  279. // CHECK:STDOUT: %.1: Greater = interface_witness_access @impl.%.1, element2 [template = constants.%struct.3]
  280. // CHECK:STDOUT: %.loc22_12: <bound method> = bound_method %a.ref, %.1
  281. // CHECK:STDOUT: %Greater.call: init bool = call %.loc22_12(%a.ref, %b.ref)
  282. // CHECK:STDOUT: %.loc22_15.1: bool = value_of_initializer %Greater.call
  283. // CHECK:STDOUT: %.loc22_15.2: bool = converted %Greater.call, %.loc22_15.1
  284. // CHECK:STDOUT: return %.loc22_15.2
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: fn @TestGreaterEqual(%a: C, %b: C) -> bool {
  288. // CHECK:STDOUT: !entry:
  289. // CHECK:STDOUT: %a.ref: C = name_ref a, %a
  290. // CHECK:STDOUT: %b.ref: C = name_ref b, %b
  291. // CHECK:STDOUT: %.1: GreaterOrEquivalent = interface_witness_access @impl.%.1, element3 [template = constants.%struct.4]
  292. // CHECK:STDOUT: %.loc26_12: <bound method> = bound_method %a.ref, %.1
  293. // CHECK:STDOUT: %GreaterOrEquivalent.call: init bool = call %.loc26_12(%a.ref, %b.ref)
  294. // CHECK:STDOUT: %.loc26_16.1: bool = value_of_initializer %GreaterOrEquivalent.call
  295. // CHECK:STDOUT: %.loc26_16.2: bool = converted %GreaterOrEquivalent.call, %.loc26_16.1
  296. // CHECK:STDOUT: return %.loc26_16.2
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: --- fail_no_impl.carbon
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: constants {
  302. // CHECK:STDOUT: %D: type = class_type @D [template]
  303. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  304. // CHECK:STDOUT: %TestLess: type = fn_type @TestLess [template]
  305. // CHECK:STDOUT: %.2: type = tuple_type () [template]
  306. // CHECK:STDOUT: %struct.1: TestLess = struct_value () [template]
  307. // CHECK:STDOUT: %.3: type = ptr_type {} [template]
  308. // CHECK:STDOUT: %.4: type = interface_type @Ordered [template]
  309. // CHECK:STDOUT: %Self: Ordered = bind_symbolic_name Self 0 [symbolic]
  310. // CHECK:STDOUT: %Less: type = fn_type @Less [template]
  311. // CHECK:STDOUT: %struct.2: Less = struct_value () [template]
  312. // CHECK:STDOUT: %.5: type = assoc_entity_type @Ordered, Less [template]
  313. // CHECK:STDOUT: %.6: <associated Less in Ordered> = assoc_entity element0, file.%import_ref.11 [template]
  314. // CHECK:STDOUT: %TestLessEqual: type = fn_type @TestLessEqual [template]
  315. // CHECK:STDOUT: %struct.3: TestLessEqual = struct_value () [template]
  316. // CHECK:STDOUT: %LessOrEquivalent: type = fn_type @LessOrEquivalent [template]
  317. // CHECK:STDOUT: %struct.4: LessOrEquivalent = struct_value () [template]
  318. // CHECK:STDOUT: %.7: type = assoc_entity_type @Ordered, LessOrEquivalent [template]
  319. // CHECK:STDOUT: %.8: <associated LessOrEquivalent in Ordered> = assoc_entity element1, file.%import_ref.13 [template]
  320. // CHECK:STDOUT: %TestGreater: type = fn_type @TestGreater [template]
  321. // CHECK:STDOUT: %struct.5: TestGreater = struct_value () [template]
  322. // CHECK:STDOUT: %Greater: type = fn_type @Greater [template]
  323. // CHECK:STDOUT: %struct.6: Greater = struct_value () [template]
  324. // CHECK:STDOUT: %.9: type = assoc_entity_type @Ordered, Greater [template]
  325. // CHECK:STDOUT: %.10: <associated Greater in Ordered> = assoc_entity element2, file.%import_ref.15 [template]
  326. // CHECK:STDOUT: %TestGreaterEqual: type = fn_type @TestGreaterEqual [template]
  327. // CHECK:STDOUT: %struct.7: TestGreaterEqual = struct_value () [template]
  328. // CHECK:STDOUT: %GreaterOrEquivalent: type = fn_type @GreaterOrEquivalent [template]
  329. // CHECK:STDOUT: %struct.8: GreaterOrEquivalent = struct_value () [template]
  330. // CHECK:STDOUT: %.11: type = assoc_entity_type @Ordered, GreaterOrEquivalent [template]
  331. // CHECK:STDOUT: %.12: <associated GreaterOrEquivalent in Ordered> = assoc_entity element3, file.%import_ref.17 [template]
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: file {
  335. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  336. // CHECK:STDOUT: .Core = %Core
  337. // CHECK:STDOUT: .D = %D.decl
  338. // CHECK:STDOUT: .TestLess = %TestLess.decl
  339. // CHECK:STDOUT: .TestLessEqual = %TestLessEqual.decl
  340. // CHECK:STDOUT: .TestGreater = %TestGreater.decl
  341. // CHECK:STDOUT: .TestGreaterEqual = %TestGreaterEqual.decl
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT: %Core: <namespace> = namespace [template] {}
  344. // CHECK:STDOUT: %D.decl: type = class_decl @D [template = constants.%D] {}
  345. // CHECK:STDOUT: %TestLess.decl: TestLess = fn_decl @TestLess [template = constants.%struct.1] {
  346. // CHECK:STDOUT: %D.ref.loc6_16: type = name_ref D, %D.decl [template = constants.%D]
  347. // CHECK:STDOUT: %a.loc6_13.1: D = param a
  348. // CHECK:STDOUT: @TestLess.%a: D = bind_name a, %a.loc6_13.1
  349. // CHECK:STDOUT: %D.ref.loc6_22: type = name_ref D, %D.decl [template = constants.%D]
  350. // CHECK:STDOUT: %b.loc6_19.1: D = param b
  351. // CHECK:STDOUT: @TestLess.%b: D = bind_name b, %b.loc6_19.1
  352. // CHECK:STDOUT: @TestLess.%return: ref bool = var <return slot>
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT: %import_ref.1: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
  355. // CHECK:STDOUT: %import_ref.2: <associated Less in Ordered> = import_ref ir6, inst+59, loaded [template = constants.%.6]
  356. // CHECK:STDOUT: %import_ref.3: <associated Greater in Ordered> = import_ref ir6, inst+93, loaded [template = constants.%.10]
  357. // CHECK:STDOUT: %import_ref.4 = import_ref ir6, inst+42, unloaded
  358. // CHECK:STDOUT: %import_ref.5: <associated LessOrEquivalent in Ordered> = import_ref ir6, inst+76, loaded [template = constants.%.8]
  359. // CHECK:STDOUT: %import_ref.6: <associated GreaterOrEquivalent in Ordered> = import_ref ir6, inst+110, loaded [template = constants.%.12]
  360. // CHECK:STDOUT: %import_ref.7 = import_ref ir6, inst+55, unloaded
  361. // CHECK:STDOUT: %import_ref.8 = import_ref ir6, inst+72, unloaded
  362. // CHECK:STDOUT: %import_ref.9 = import_ref ir6, inst+89, unloaded
  363. // CHECK:STDOUT: %import_ref.10 = import_ref ir6, inst+106, unloaded
  364. // CHECK:STDOUT: %import_ref.11 = import_ref ir6, inst+55, unloaded
  365. // CHECK:STDOUT: %TestLessEqual.decl: TestLessEqual = fn_decl @TestLessEqual [template = constants.%struct.3] {
  366. // CHECK:STDOUT: %D.ref.loc14_21: type = name_ref D, %D.decl [template = constants.%D]
  367. // CHECK:STDOUT: %a.loc14_18.1: D = param a
  368. // CHECK:STDOUT: @TestLessEqual.%a: D = bind_name a, %a.loc14_18.1
  369. // CHECK:STDOUT: %D.ref.loc14_27: type = name_ref D, %D.decl [template = constants.%D]
  370. // CHECK:STDOUT: %b.loc14_24.1: D = param b
  371. // CHECK:STDOUT: @TestLessEqual.%b: D = bind_name b, %b.loc14_24.1
  372. // CHECK:STDOUT: @TestLessEqual.%return: ref bool = var <return slot>
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT: %import_ref.12: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
  375. // CHECK:STDOUT: %import_ref.13 = import_ref ir6, inst+72, unloaded
  376. // CHECK:STDOUT: %TestGreater.decl: TestGreater = fn_decl @TestGreater [template = constants.%struct.5] {
  377. // CHECK:STDOUT: %D.ref.loc22_19: type = name_ref D, %D.decl [template = constants.%D]
  378. // CHECK:STDOUT: %a.loc22_16.1: D = param a
  379. // CHECK:STDOUT: @TestGreater.%a: D = bind_name a, %a.loc22_16.1
  380. // CHECK:STDOUT: %D.ref.loc22_25: type = name_ref D, %D.decl [template = constants.%D]
  381. // CHECK:STDOUT: %b.loc22_22.1: D = param b
  382. // CHECK:STDOUT: @TestGreater.%b: D = bind_name b, %b.loc22_22.1
  383. // CHECK:STDOUT: @TestGreater.%return: ref bool = var <return slot>
  384. // CHECK:STDOUT: }
  385. // CHECK:STDOUT: %import_ref.14: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
  386. // CHECK:STDOUT: %import_ref.15 = import_ref ir6, inst+89, unloaded
  387. // CHECK:STDOUT: %TestGreaterEqual.decl: TestGreaterEqual = fn_decl @TestGreaterEqual [template = constants.%struct.7] {
  388. // CHECK:STDOUT: %D.ref.loc30_24: type = name_ref D, %D.decl [template = constants.%D]
  389. // CHECK:STDOUT: %a.loc30_21.1: D = param a
  390. // CHECK:STDOUT: @TestGreaterEqual.%a: D = bind_name a, %a.loc30_21.1
  391. // CHECK:STDOUT: %D.ref.loc30_30: type = name_ref D, %D.decl [template = constants.%D]
  392. // CHECK:STDOUT: %b.loc30_27.1: D = param b
  393. // CHECK:STDOUT: @TestGreaterEqual.%b: D = bind_name b, %b.loc30_27.1
  394. // CHECK:STDOUT: @TestGreaterEqual.%return: ref bool = var <return slot>
  395. // CHECK:STDOUT: }
  396. // CHECK:STDOUT: %import_ref.16: type = import_ref ir6, inst+40, loaded [template = constants.%.4]
  397. // CHECK:STDOUT: %import_ref.17 = import_ref ir6, inst+106, unloaded
  398. // CHECK:STDOUT: }
  399. // CHECK:STDOUT:
  400. // CHECK:STDOUT: interface @Ordered {
  401. // CHECK:STDOUT: !members:
  402. // CHECK:STDOUT: .Less = file.%import_ref.2
  403. // CHECK:STDOUT: .Greater = file.%import_ref.3
  404. // CHECK:STDOUT: .Self = file.%import_ref.4
  405. // CHECK:STDOUT: .LessOrEquivalent = file.%import_ref.5
  406. // CHECK:STDOUT: .GreaterOrEquivalent = file.%import_ref.6
  407. // CHECK:STDOUT: witness = (file.%import_ref.7, file.%import_ref.8, file.%import_ref.9, file.%import_ref.10)
  408. // CHECK:STDOUT: }
  409. // CHECK:STDOUT:
  410. // CHECK:STDOUT: class @D {
  411. // CHECK:STDOUT: !members:
  412. // CHECK:STDOUT: .Self = constants.%D
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: fn @TestLess(%a: D, %b: D) -> bool {
  416. // CHECK:STDOUT: !entry:
  417. // CHECK:STDOUT: %a.ref: D = name_ref a, %a
  418. // CHECK:STDOUT: %b.ref: D = name_ref b, %b
  419. // CHECK:STDOUT: return <error>
  420. // CHECK:STDOUT: }
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: fn @Less[%self: Self](%other: Self) -> bool;
  423. // CHECK:STDOUT:
  424. // CHECK:STDOUT: fn @TestLessEqual(%a: D, %b: D) -> bool {
  425. // CHECK:STDOUT: !entry:
  426. // CHECK:STDOUT: %a.ref: D = name_ref a, %a
  427. // CHECK:STDOUT: %b.ref: D = name_ref b, %b
  428. // CHECK:STDOUT: return <error>
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: fn @LessOrEquivalent[%self: Self](%other: Self) -> bool;
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: fn @TestGreater(%a: D, %b: D) -> bool {
  434. // CHECK:STDOUT: !entry:
  435. // CHECK:STDOUT: %a.ref: D = name_ref a, %a
  436. // CHECK:STDOUT: %b.ref: D = name_ref b, %b
  437. // CHECK:STDOUT: return <error>
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: fn @Greater[%self: Self](%other: Self) -> bool;
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: fn @TestGreaterEqual(%a: D, %b: D) -> bool {
  443. // CHECK:STDOUT: !entry:
  444. // CHECK:STDOUT: %a.ref: D = name_ref a, %a
  445. // CHECK:STDOUT: %b.ref: D = name_ref b, %b
  446. // CHECK:STDOUT: return <error>
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: fn @GreaterOrEquivalent[%self: Self](%other: Self) -> bool;
  450. // CHECK:STDOUT: