destroy_calls.carbon 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/destroy.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/class/destroy_calls.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/destroy_calls.carbon
  12. // --- implicit_return.carbon
  13. library "[[@TEST_NAME]]";
  14. class A {}
  15. class B {}
  16. class C {}
  17. //@dump-sem-ir-begin
  18. fn F() {
  19. var a: A;
  20. var b: B;
  21. var c: C;
  22. }
  23. //@dump-sem-ir-end
  24. // --- nested_scope.carbon
  25. library "[[@TEST_NAME]]";
  26. class A {}
  27. class B {}
  28. class C {}
  29. //@dump-sem-ir-begin
  30. fn F() {
  31. var a: A;
  32. var b: B;
  33. if (true) {
  34. var c: C;
  35. }
  36. }
  37. //@dump-sem-ir-end
  38. // --- temp.carbon
  39. library "[[@TEST_NAME]]";
  40. class A { fn Make() -> A; }
  41. class B { fn Make() -> B; }
  42. class C { fn Make() -> C; }
  43. //@dump-sem-ir-begin
  44. fn F() {
  45. // TODO: The scoping of these destroy calls is incorrect. Maybe we need to
  46. // establish statement scopes?
  47. A.Make();
  48. B.Make();
  49. C.Make();
  50. }
  51. //@dump-sem-ir-end
  52. // --- generic_class.carbon
  53. library "[[@TEST_NAME]]";
  54. class C {}
  55. class D(template T:! type) {}
  56. //@dump-sem-ir-begin
  57. fn F() {
  58. var a: D(C);
  59. }
  60. //@dump-sem-ir-end
  61. // --- generic_use_inside_generic.carbon
  62. library "[[@TEST_NAME]]";
  63. class C(template T:! type) {}
  64. //@dump-sem-ir-begin
  65. fn F(template T:! type) {
  66. var v: C(T);
  67. }
  68. //@dump-sem-ir-end
  69. fn G() { F({}); }
  70. // CHECK:STDOUT: --- implicit_return.carbon
  71. // CHECK:STDOUT:
  72. // CHECK:STDOUT: constants {
  73. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  74. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  75. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  76. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  77. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  78. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  79. // CHECK:STDOUT: %pattern_type.c10: type = pattern_type %A [concrete]
  80. // CHECK:STDOUT: %pattern_type.049: type = pattern_type %B [concrete]
  81. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  82. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  83. // CHECK:STDOUT: %facet_value.be8: %type_where = facet_value %C, () [concrete]
  84. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.eeb: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.be8) [concrete]
  85. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.88a: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.eeb = struct_value () [concrete]
  86. // CHECK:STDOUT: %facet_value.5f2: %type_where = facet_value %B, () [concrete]
  87. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.a6c: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.5f2) [concrete]
  88. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.0ba: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.a6c = struct_value () [concrete]
  89. // CHECK:STDOUT: %facet_value.bb7: %type_where = facet_value %A, () [concrete]
  90. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.744: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.bb7) [concrete]
  91. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.657: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.744 = struct_value () [concrete]
  92. // CHECK:STDOUT: }
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: imports {
  95. // CHECK:STDOUT: }
  96. // CHECK:STDOUT:
  97. // CHECK:STDOUT: file {
  98. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  99. // CHECK:STDOUT: }
  100. // CHECK:STDOUT:
  101. // CHECK:STDOUT: fn @F() {
  102. // CHECK:STDOUT: !entry:
  103. // CHECK:STDOUT: name_binding_decl {
  104. // CHECK:STDOUT: %a.patt: %pattern_type.c10 = ref_binding_pattern a [concrete]
  105. // CHECK:STDOUT: %a.var_patt: %pattern_type.c10 = var_pattern %a.patt [concrete]
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT: %a.var: ref %A = var %a.var_patt
  108. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  109. // CHECK:STDOUT: %a: ref %A = ref_binding a, %a.var
  110. // CHECK:STDOUT: name_binding_decl {
  111. // CHECK:STDOUT: %b.patt: %pattern_type.049 = ref_binding_pattern b [concrete]
  112. // CHECK:STDOUT: %b.var_patt: %pattern_type.049 = var_pattern %b.patt [concrete]
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT: %b.var: ref %B = var %b.var_patt
  115. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  116. // CHECK:STDOUT: %b: ref %B = ref_binding b, %b.var
  117. // CHECK:STDOUT: name_binding_decl {
  118. // CHECK:STDOUT: %c.patt: %pattern_type.c48 = ref_binding_pattern c [concrete]
  119. // CHECK:STDOUT: %c.var_patt: %pattern_type.c48 = var_pattern %c.patt [concrete]
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt
  122. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  123. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var
  124. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc12: <bound method> = bound_method %c.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.88a
  125. // CHECK:STDOUT: <elided>
  126. // CHECK:STDOUT: %bound_method.loc12: <bound method> = bound_method %c.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.1
  127. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc12: init %empty_tuple.type = call %bound_method.loc12(%c.var)
  128. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc11: <bound method> = bound_method %b.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.0ba
  129. // CHECK:STDOUT: <elided>
  130. // CHECK:STDOUT: %bound_method.loc11: <bound method> = bound_method %b.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.2
  131. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc11: init %empty_tuple.type = call %bound_method.loc11(%b.var)
  132. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc10: <bound method> = bound_method %a.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.657
  133. // CHECK:STDOUT: <elided>
  134. // CHECK:STDOUT: %bound_method.loc10: <bound method> = bound_method %a.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.3
  135. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc10: init %empty_tuple.type = call %bound_method.loc10(%a.var)
  136. // CHECK:STDOUT: return
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT:
  139. // CHECK:STDOUT: --- nested_scope.carbon
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: constants {
  142. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  143. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  144. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  145. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  146. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  147. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  148. // CHECK:STDOUT: %pattern_type.c10: type = pattern_type %A [concrete]
  149. // CHECK:STDOUT: %pattern_type.049: type = pattern_type %B [concrete]
  150. // CHECK:STDOUT: %true: bool = bool_literal true [concrete]
  151. // CHECK:STDOUT: %pattern_type.c48: type = pattern_type %C [concrete]
  152. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  153. // CHECK:STDOUT: %facet_value.be8: %type_where = facet_value %C, () [concrete]
  154. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.eeb: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.be8) [concrete]
  155. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.88a: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.eeb = struct_value () [concrete]
  156. // CHECK:STDOUT: %facet_value.5f2: %type_where = facet_value %B, () [concrete]
  157. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.a6c: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.5f2) [concrete]
  158. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.0ba: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.a6c = struct_value () [concrete]
  159. // CHECK:STDOUT: %facet_value.bb7: %type_where = facet_value %A, () [concrete]
  160. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.744: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.bb7) [concrete]
  161. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.657: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.744 = struct_value () [concrete]
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: imports {
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT:
  167. // CHECK:STDOUT: file {
  168. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  169. // CHECK:STDOUT: }
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: fn @F() {
  172. // CHECK:STDOUT: !entry:
  173. // CHECK:STDOUT: name_binding_decl {
  174. // CHECK:STDOUT: %a.patt: %pattern_type.c10 = ref_binding_pattern a [concrete]
  175. // CHECK:STDOUT: %a.var_patt: %pattern_type.c10 = var_pattern %a.patt [concrete]
  176. // CHECK:STDOUT: }
  177. // CHECK:STDOUT: %a.var: ref %A = var %a.var_patt
  178. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  179. // CHECK:STDOUT: %a: ref %A = ref_binding a, %a.var
  180. // CHECK:STDOUT: name_binding_decl {
  181. // CHECK:STDOUT: %b.patt: %pattern_type.049 = ref_binding_pattern b [concrete]
  182. // CHECK:STDOUT: %b.var_patt: %pattern_type.049 = var_pattern %b.patt [concrete]
  183. // CHECK:STDOUT: }
  184. // CHECK:STDOUT: %b.var: ref %B = var %b.var_patt
  185. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  186. // CHECK:STDOUT: %b: ref %B = ref_binding b, %b.var
  187. // CHECK:STDOUT: %true: bool = bool_literal true [concrete = constants.%true]
  188. // CHECK:STDOUT: if %true br !if.then else br !if.else
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: !if.then:
  191. // CHECK:STDOUT: name_binding_decl {
  192. // CHECK:STDOUT: %c.patt: %pattern_type.c48 = ref_binding_pattern c [concrete]
  193. // CHECK:STDOUT: %c.var_patt: %pattern_type.c48 = var_pattern %c.patt [concrete]
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT: %c.var: ref %C = var %c.var_patt
  196. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  197. // CHECK:STDOUT: %c: ref %C = ref_binding c, %c.var
  198. // CHECK:STDOUT: br !if.else
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: !if.else:
  201. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc13: <bound method> = bound_method %c.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.88a
  202. // CHECK:STDOUT: <elided>
  203. // CHECK:STDOUT: %bound_method.loc13: <bound method> = bound_method %c.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.1
  204. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc13: init %empty_tuple.type = call %bound_method.loc13(%c.var)
  205. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc11: <bound method> = bound_method %b.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.0ba
  206. // CHECK:STDOUT: <elided>
  207. // CHECK:STDOUT: %bound_method.loc11: <bound method> = bound_method %b.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.2
  208. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc11: init %empty_tuple.type = call %bound_method.loc11(%b.var)
  209. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc10: <bound method> = bound_method %a.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.657
  210. // CHECK:STDOUT: <elided>
  211. // CHECK:STDOUT: %bound_method.loc10: <bound method> = bound_method %a.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.3
  212. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc10: init %empty_tuple.type = call %bound_method.loc10(%a.var)
  213. // CHECK:STDOUT: return
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: --- temp.carbon
  217. // CHECK:STDOUT:
  218. // CHECK:STDOUT: constants {
  219. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  220. // CHECK:STDOUT: %A.Make.type: type = fn_type @A.Make [concrete]
  221. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  222. // CHECK:STDOUT: %A.Make: %A.Make.type = struct_value () [concrete]
  223. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  224. // CHECK:STDOUT: %B.Make.type: type = fn_type @B.Make [concrete]
  225. // CHECK:STDOUT: %B.Make: %B.Make.type = struct_value () [concrete]
  226. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  227. // CHECK:STDOUT: %C.Make.type: type = fn_type @C.Make [concrete]
  228. // CHECK:STDOUT: %C.Make: %C.Make.type = struct_value () [concrete]
  229. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  230. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  231. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  232. // CHECK:STDOUT: %facet_value.be8: %type_where = facet_value %C, () [concrete]
  233. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.eeb: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.be8) [concrete]
  234. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.88a: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.eeb = struct_value () [concrete]
  235. // CHECK:STDOUT: %facet_value.5f2: %type_where = facet_value %B, () [concrete]
  236. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.a6c: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.5f2) [concrete]
  237. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.0ba: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.a6c = struct_value () [concrete]
  238. // CHECK:STDOUT: %facet_value.bb7: %type_where = facet_value %A, () [concrete]
  239. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.744: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.bb7) [concrete]
  240. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.657: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.744 = struct_value () [concrete]
  241. // CHECK:STDOUT: }
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: imports {
  244. // CHECK:STDOUT: }
  245. // CHECK:STDOUT:
  246. // CHECK:STDOUT: file {
  247. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: fn @F() {
  251. // CHECK:STDOUT: !entry:
  252. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  253. // CHECK:STDOUT: %Make.ref.loc12: %A.Make.type = name_ref Make, @A.%A.Make.decl [concrete = constants.%A.Make]
  254. // CHECK:STDOUT: %.loc12_10.1: ref %A = temporary_storage
  255. // CHECK:STDOUT: %A.Make.call: init %A = call %Make.ref.loc12() to %.loc12_10.1
  256. // CHECK:STDOUT: %.loc12_10.2: ref %A = temporary %.loc12_10.1, %A.Make.call
  257. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  258. // CHECK:STDOUT: %Make.ref.loc13: %B.Make.type = name_ref Make, @B.%B.Make.decl [concrete = constants.%B.Make]
  259. // CHECK:STDOUT: %.loc13_10.1: ref %B = temporary_storage
  260. // CHECK:STDOUT: %B.Make.call: init %B = call %Make.ref.loc13() to %.loc13_10.1
  261. // CHECK:STDOUT: %.loc13_10.2: ref %B = temporary %.loc13_10.1, %B.Make.call
  262. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  263. // CHECK:STDOUT: %Make.ref.loc14: %C.Make.type = name_ref Make, @C.%C.Make.decl [concrete = constants.%C.Make]
  264. // CHECK:STDOUT: %.loc14_10.1: ref %C = temporary_storage
  265. // CHECK:STDOUT: %C.Make.call: init %C = call %Make.ref.loc14() to %.loc14_10.1
  266. // CHECK:STDOUT: %.loc14_10.2: ref %C = temporary %.loc14_10.1, %C.Make.call
  267. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc14: <bound method> = bound_method %.loc14_10.2, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.88a
  268. // CHECK:STDOUT: <elided>
  269. // CHECK:STDOUT: %bound_method.loc14: <bound method> = bound_method %.loc14_10.2, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.1
  270. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc14: init %empty_tuple.type = call %bound_method.loc14(%.loc14_10.2)
  271. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc13: <bound method> = bound_method %.loc13_10.2, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.0ba
  272. // CHECK:STDOUT: <elided>
  273. // CHECK:STDOUT: %bound_method.loc13: <bound method> = bound_method %.loc13_10.2, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.2
  274. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc13: init %empty_tuple.type = call %bound_method.loc13(%.loc13_10.2)
  275. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound.loc12: <bound method> = bound_method %.loc12_10.2, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.657
  276. // CHECK:STDOUT: <elided>
  277. // CHECK:STDOUT: %bound_method.loc12: <bound method> = bound_method %.loc12_10.2, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.3
  278. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call.loc12: init %empty_tuple.type = call %bound_method.loc12(%.loc12_10.2)
  279. // CHECK:STDOUT: return
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: --- generic_class.carbon
  283. // CHECK:STDOUT:
  284. // CHECK:STDOUT: constants {
  285. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  286. // CHECK:STDOUT: %D.type: type = generic_class_type @D [concrete]
  287. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  288. // CHECK:STDOUT: %D.generic: %D.type = struct_value () [concrete]
  289. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  290. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  291. // CHECK:STDOUT: %D.113: type = class_type @D, @D(%C) [concrete]
  292. // CHECK:STDOUT: %pattern_type.c95: type = pattern_type %D.113 [concrete]
  293. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  294. // CHECK:STDOUT: %facet_value: %type_where = facet_value %D.113, () [concrete]
  295. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.771: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [concrete]
  296. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.58f: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.771 = struct_value () [concrete]
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: imports {
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: file {
  303. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {} {}
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: fn @F() {
  307. // CHECK:STDOUT: !entry:
  308. // CHECK:STDOUT: name_binding_decl {
  309. // CHECK:STDOUT: %a.patt: %pattern_type.c95 = ref_binding_pattern a [concrete]
  310. // CHECK:STDOUT: %a.var_patt: %pattern_type.c95 = var_pattern %a.patt [concrete]
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT: %a.var: ref %D.113 = var %a.var_patt
  313. // CHECK:STDOUT: %.loc9: type = splice_block %D [concrete = constants.%D.113] {
  314. // CHECK:STDOUT: %D.ref: %D.type = name_ref D, file.%D.decl [concrete = constants.%D.generic]
  315. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  316. // CHECK:STDOUT: %D: type = class_type @D, @D(constants.%C) [concrete = constants.%D.113]
  317. // CHECK:STDOUT: }
  318. // CHECK:STDOUT: %a: ref %D.113 = ref_binding a, %a.var
  319. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.bound: <bound method> = bound_method %a.var, constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.58f
  320. // CHECK:STDOUT: <elided>
  321. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %a.var, %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn
  322. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method(%a.var)
  323. // CHECK:STDOUT: return
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: --- generic_use_inside_generic.carbon
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: constants {
  329. // CHECK:STDOUT: %T: type = symbolic_binding T, 0, template [template]
  330. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  331. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  332. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  333. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  334. // CHECK:STDOUT: %C.3f0: type = class_type @C, @C(%T) [template]
  335. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  336. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  337. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  338. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  339. // CHECK:STDOUT: %require_complete.c98: <witness> = require_complete_type %C.3f0 [template]
  340. // CHECK:STDOUT: %pattern_type.06f: type = pattern_type %C.3f0 [template]
  341. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  342. // CHECK:STDOUT: %Destroy.Op.type: type = fn_type @Destroy.Op [concrete]
  343. // CHECK:STDOUT: %type_where: type = facet_type <type where .Self impls <CanDestroy>> [concrete]
  344. // CHECK:STDOUT: %DestroyT: %type_where = symbolic_binding DestroyT, 0 [symbolic]
  345. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.15c: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%DestroyT) [symbolic]
  346. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.fd5: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.15c = struct_value () [symbolic]
  347. // CHECK:STDOUT: %facet_value.bf8: %type_where = facet_value %C.3f0, () [template]
  348. // CHECK:STDOUT: %Destroy.impl_witness.a59: <witness> = impl_witness imports.%Destroy.impl_witness_table, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.bf8) [template]
  349. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.7d9: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.bf8) [template]
  350. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.76f: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.7d9 = struct_value () [template]
  351. // CHECK:STDOUT: %Destroy.facet.a5b: %Destroy.type = facet_value %C.3f0, (%Destroy.impl_witness.a59) [template]
  352. // CHECK:STDOUT: %.4c5: type = fn_type_with_self_type %Destroy.Op.type, %Destroy.facet.a5b [template]
  353. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.5e4: <specific function> = specific_function %DestroyT.binding.as_type.as.Destroy.impl.Op.76f, @DestroyT.binding.as_type.as.Destroy.impl.Op(%facet_value.bf8) [template]
  354. // CHECK:STDOUT: %C.7a7: type = class_type @C, @C(%empty_struct_type) [concrete]
  355. // CHECK:STDOUT: %pattern_type.99a: type = pattern_type %C.7a7 [concrete]
  356. // CHECK:STDOUT: %facet_value.036: %type_where = facet_value %C.7a7, () [concrete]
  357. // CHECK:STDOUT: %Destroy.impl_witness.8e7: <witness> = impl_witness imports.%Destroy.impl_witness_table, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.036) [concrete]
  358. // CHECK:STDOUT: %Destroy.facet.056: %Destroy.type = facet_value %C.7a7, (%Destroy.impl_witness.8e7) [concrete]
  359. // CHECK:STDOUT: %.1c0: type = fn_type_with_self_type %Destroy.Op.type, %Destroy.facet.056 [concrete]
  360. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.c3a: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value.036) [concrete]
  361. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.b3a: %DestroyT.binding.as_type.as.Destroy.impl.Op.type.c3a = struct_value () [concrete]
  362. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.a93: <specific function> = specific_function %DestroyT.binding.as_type.as.Destroy.impl.Op.b3a, @DestroyT.binding.as_type.as.Destroy.impl.Op(%facet_value.036) [concrete]
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: imports {
  366. // CHECK:STDOUT: %Core.import_ref.5c4: @DestroyT.binding.as_type.as.Destroy.impl.%DestroyT.binding.as_type.as.Destroy.impl.Op.type (%DestroyT.binding.as_type.as.Destroy.impl.Op.type.15c) = import_ref Core//prelude/parts/destroy, loc{{\d+_\d+}}, loaded [symbolic = @DestroyT.binding.as_type.as.Destroy.impl.%DestroyT.binding.as_type.as.Destroy.impl.Op (constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.fd5)]
  367. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (%Core.import_ref.5c4), @DestroyT.binding.as_type.as.Destroy.impl [concrete]
  368. // CHECK:STDOUT: }
  369. // CHECK:STDOUT:
  370. // CHECK:STDOUT: file {
  371. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  372. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0, template [concrete]
  373. // CHECK:STDOUT: } {
  374. // CHECK:STDOUT: <elided>
  375. // CHECK:STDOUT: %T.loc6_15.2: type = symbolic_binding T, 0, template [template = %T.loc6_15.1 (constants.%T)]
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: generic fn @F(%T.loc6_15.2: type) {
  380. // CHECK:STDOUT: %T.loc6_15.1: type = symbolic_binding T, 0, template [template = %T.loc6_15.1 (constants.%T)]
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: !definition:
  383. // CHECK:STDOUT: %C.loc7_13.2: type = class_type @C, @C(%T.loc6_15.1) [template = %C.loc7_13.2 (constants.%C.3f0)]
  384. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %C.loc7_13.2 [template = %require_complete (constants.%require_complete.c98)]
  385. // CHECK:STDOUT: %pattern_type: type = pattern_type %C.loc7_13.2 [template = %pattern_type (constants.%pattern_type.06f)]
  386. // CHECK:STDOUT: %facet_value: %type_where = facet_value %C.loc7_13.2, () [template = %facet_value (constants.%facet_value.bf8)]
  387. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness imports.%Destroy.impl_witness_table, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [template = %Destroy.impl_witness (constants.%Destroy.impl_witness.a59)]
  388. // CHECK:STDOUT: %Destroy.facet: %Destroy.type = facet_value %C.loc7_13.2, (%Destroy.impl_witness) [template = %Destroy.facet (constants.%Destroy.facet.a5b)]
  389. // CHECK:STDOUT: %.loc7_3: type = fn_type_with_self_type constants.%Destroy.Op.type, %Destroy.facet [template = %.loc7_3 (constants.%.4c5)]
  390. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type: type = fn_type @DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl(%facet_value) [template = %DestroyT.binding.as_type.as.Destroy.impl.Op.type (constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.type.7d9)]
  391. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op: @F.%DestroyT.binding.as_type.as.Destroy.impl.Op.type (%DestroyT.binding.as_type.as.Destroy.impl.Op.type.7d9) = struct_value () [template = %DestroyT.binding.as_type.as.Destroy.impl.Op (constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.76f)]
  392. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn: <specific function> = specific_function %DestroyT.binding.as_type.as.Destroy.impl.Op, @DestroyT.binding.as_type.as.Destroy.impl.Op(%facet_value) [template = %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn (constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.5e4)]
  393. // CHECK:STDOUT:
  394. // CHECK:STDOUT: fn() {
  395. // CHECK:STDOUT: !entry:
  396. // CHECK:STDOUT: name_binding_decl {
  397. // CHECK:STDOUT: %v.patt: @F.%pattern_type (%pattern_type.06f) = ref_binding_pattern v [concrete]
  398. // CHECK:STDOUT: %v.var_patt: @F.%pattern_type (%pattern_type.06f) = var_pattern %v.patt [concrete]
  399. // CHECK:STDOUT: }
  400. // CHECK:STDOUT: %v.var: ref @F.%C.loc7_13.2 (%C.3f0) = var %v.var_patt
  401. // CHECK:STDOUT: %.loc7_13: type = splice_block %C.loc7_13.1 [template = %C.loc7_13.2 (constants.%C.3f0)] {
  402. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [concrete = constants.%C.generic]
  403. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc6_15.2 [template = %T.loc6_15.1 (constants.%T)]
  404. // CHECK:STDOUT: %C.loc7_13.1: type = class_type @C, @C(constants.%T) [template = %C.loc7_13.2 (constants.%C.3f0)]
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT: %v: ref @F.%C.loc7_13.2 (%C.3f0) = ref_binding v, %v.var
  407. // CHECK:STDOUT: %impl.elem0: @F.%.loc7_3 (%.4c5) = impl_witness_access constants.%Destroy.impl_witness.a59, element0 [template = %DestroyT.binding.as_type.as.Destroy.impl.Op (constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.76f)]
  408. // CHECK:STDOUT: %bound_method.loc7_3.1: <bound method> = bound_method %v.var, %impl.elem0
  409. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @DestroyT.binding.as_type.as.Destroy.impl.Op(constants.%facet_value.bf8) [template = %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn (constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.5e4)]
  410. // CHECK:STDOUT: %bound_method.loc7_3.2: <bound method> = bound_method %v.var, %specific_fn
  411. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.call: init %empty_tuple.type = call %bound_method.loc7_3.2(%v.var)
  412. // CHECK:STDOUT: return
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT: }
  415. // CHECK:STDOUT:
  416. // CHECK:STDOUT: specific @F(constants.%T) {
  417. // CHECK:STDOUT: %T.loc6_15.1 => constants.%T
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: specific @F(constants.%empty_struct_type) {
  421. // CHECK:STDOUT: %T.loc6_15.1 => constants.%empty_struct_type
  422. // CHECK:STDOUT:
  423. // CHECK:STDOUT: !definition:
  424. // CHECK:STDOUT: %C.loc7_13.2 => constants.%C.7a7
  425. // CHECK:STDOUT: %require_complete => constants.%complete_type
  426. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.99a
  427. // CHECK:STDOUT: %facet_value => constants.%facet_value.036
  428. // CHECK:STDOUT: %Destroy.impl_witness => constants.%Destroy.impl_witness.8e7
  429. // CHECK:STDOUT: %Destroy.facet => constants.%Destroy.facet.056
  430. // CHECK:STDOUT: %.loc7_3 => constants.%.1c0
  431. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.type => constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.type.c3a
  432. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op => constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.b3a
  433. // CHECK:STDOUT: %DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn => constants.%DestroyT.binding.as_type.as.Destroy.impl.Op.specific_fn.a93
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT: