ordered.carbon 41 KB

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