compound.carbon 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/no_prelude/compound.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/compound.carbon
  10. // --- core.carbon
  11. package Core;
  12. interface ImplicitAs(Dest:! type) {
  13. fn Convert[self: Self]() -> Dest;
  14. }
  15. // --- fail_todo_non-instance_success.carbon
  16. library "[[@TEST_NAME]]";
  17. interface NonInstance1 {
  18. fn F1();
  19. }
  20. impl {.a: ()} as NonInstance1 {
  21. fn F1() {}
  22. }
  23. fn NonInstanceCall1() {
  24. // CHECK:STDERR: fail_todo_non-instance_success.carbon:[[@LINE+4]]:3: error: cannot access member of interface `NonInstance1` in type `type` that does not implement that interface [MissingImplInMemberAccess]
  25. // CHECK:STDERR: {.a: ()}.(NonInstance1.F1)();
  26. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~
  27. // CHECK:STDERR:
  28. {.a: ()}.(NonInstance1.F1)();
  29. }
  30. // --- todo_fail_non-instance.carbon
  31. library "[[@TEST_NAME]]";
  32. import Core;
  33. interface NonInstance2 {
  34. fn F2();
  35. }
  36. impl {.b: ()} as NonInstance2 {
  37. fn F2() {}
  38. }
  39. fn NonInstanceCall2(n: {.b: ()}) {
  40. n.(NonInstance2.F2)();
  41. }
  42. // --- todo_fail_non-instance_indirect.carbon
  43. library "[[@TEST_NAME]]";
  44. import Core;
  45. interface NonInstance3 {
  46. fn F3();
  47. }
  48. impl {.c: ()} as NonInstance3 {
  49. fn F3() {}
  50. }
  51. fn NonInstanceCallIndirect(p: {.c: ()}*) {
  52. p->(NonInstance3.F3)();
  53. }
  54. // --- instance_success.carbon
  55. library "[[@TEST_NAME]]";
  56. interface Instance1 {
  57. fn G1[self: Self]();
  58. }
  59. impl {.d: ()} as Instance1 {
  60. fn G1[self: Self]() {}
  61. }
  62. fn InstanceCall(n: {.d: ()}) {
  63. n.(Instance1.G1)();
  64. }
  65. fn InstanceCallIndirect(p: {.d: ()}*) {
  66. p->(Instance1.G1)();
  67. }
  68. // --- fail_instance.carbon
  69. library "[[@TEST_NAME]]";
  70. interface Instance2 {
  71. fn G2[self: Self]();
  72. }
  73. impl {.e: ()} as Instance2 {
  74. fn G2[self: Self]() {}
  75. }
  76. fn InstanceCallFail() {
  77. // CHECK:STDERR: fail_instance.carbon:[[@LINE+4]]:3: error: cannot access member of interface `Instance2` in type `type` that does not implement that interface [MissingImplInMemberAccess]
  78. // CHECK:STDERR: {.e: ()}.(Instance2.G2)();
  79. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~
  80. // CHECK:STDERR:
  81. {.e: ()}.(Instance2.G2)();
  82. }
  83. // CHECK:STDOUT: --- core.carbon
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: constants {
  86. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic]
  87. // CHECK:STDOUT: %Dest.patt: type = symbolic_binding_pattern Dest, 0 [symbolic]
  88. // CHECK:STDOUT: %ImplicitAs.type.96f: type = generic_interface_type @ImplicitAs [concrete]
  89. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.96f = struct_value () [concrete]
  90. // CHECK:STDOUT: %ImplicitAs.type.07f: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
  91. // CHECK:STDOUT: %Self: %ImplicitAs.type.07f = bind_symbolic_name Self, 1 [symbolic]
  92. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  93. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest) [symbolic]
  94. // CHECK:STDOUT: %Convert: %Convert.type = struct_value () [symbolic]
  95. // CHECK:STDOUT: %ImplicitAs.assoc_type: type = assoc_entity_type %ImplicitAs.type.07f [symbolic]
  96. // CHECK:STDOUT: %assoc0: %ImplicitAs.assoc_type = assoc_entity element0, @ImplicitAs.%Convert.decl [symbolic]
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: file {
  100. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  101. // CHECK:STDOUT: .ImplicitAs = %ImplicitAs.decl
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %ImplicitAs.decl: %ImplicitAs.type.96f = interface_decl @ImplicitAs [concrete = constants.%ImplicitAs.generic] {
  104. // CHECK:STDOUT: %Dest.patt.loc3_22.1: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt.loc3_22.2 (constants.%Dest.patt)]
  105. // CHECK:STDOUT: } {
  106. // CHECK:STDOUT: %Dest.loc3_22.1: type = bind_symbolic_name Dest, 0 [symbolic = %Dest.loc3_22.2 (constants.%Dest)]
  107. // CHECK:STDOUT: }
  108. // CHECK:STDOUT: }
  109. // CHECK:STDOUT:
  110. // CHECK:STDOUT: generic interface @ImplicitAs(%Dest.loc3_22.1: type) {
  111. // CHECK:STDOUT: %Dest.loc3_22.2: type = bind_symbolic_name Dest, 0 [symbolic = %Dest.loc3_22.2 (constants.%Dest)]
  112. // CHECK:STDOUT: %Dest.patt.loc3_22.2: type = symbolic_binding_pattern Dest, 0 [symbolic = %Dest.patt.loc3_22.2 (constants.%Dest.patt)]
  113. // CHECK:STDOUT:
  114. // CHECK:STDOUT: !definition:
  115. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest.loc3_22.2)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.07f)]
  116. // CHECK:STDOUT: %Self.2: %ImplicitAs.type.07f = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  117. // CHECK:STDOUT: %Convert.type: type = fn_type @Convert, @ImplicitAs(%Dest.loc3_22.2) [symbolic = %Convert.type (constants.%Convert.type)]
  118. // CHECK:STDOUT: %Convert: @ImplicitAs.%Convert.type (%Convert.type) = struct_value () [symbolic = %Convert (constants.%Convert)]
  119. // CHECK:STDOUT: %ImplicitAs.assoc_type: type = assoc_entity_type @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.07f) [symbolic = %ImplicitAs.assoc_type (constants.%ImplicitAs.assoc_type)]
  120. // CHECK:STDOUT: %assoc0.loc4_35.2: @ImplicitAs.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type) = assoc_entity element0, %Convert.decl [symbolic = %assoc0.loc4_35.2 (constants.%assoc0)]
  121. // CHECK:STDOUT:
  122. // CHECK:STDOUT: interface {
  123. // CHECK:STDOUT: %Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.07f) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  124. // CHECK:STDOUT: %Convert.decl: @ImplicitAs.%Convert.type (%Convert.type) = fn_decl @Convert [symbolic = @ImplicitAs.%Convert (constants.%Convert)] {
  125. // CHECK:STDOUT: %self.patt: @Convert.%Self.as_type.loc4_20.1 (%Self.as_type) = binding_pattern self
  126. // CHECK:STDOUT: %self.param_patt: @Convert.%Self.as_type.loc4_20.1 (%Self.as_type) = value_param_pattern %self.patt, call_param0
  127. // CHECK:STDOUT: %return.patt: @Convert.%Dest (%Dest) = return_slot_pattern
  128. // CHECK:STDOUT: %return.param_patt: @Convert.%Dest (%Dest) = out_param_pattern %return.patt, call_param1
  129. // CHECK:STDOUT: } {
  130. // CHECK:STDOUT: %Dest.ref: type = name_ref Dest, @ImplicitAs.%Dest.loc3_22.1 [symbolic = %Dest (constants.%Dest)]
  131. // CHECK:STDOUT: %self.param: @Convert.%Self.as_type.loc4_20.1 (%Self.as_type) = value_param call_param0
  132. // CHECK:STDOUT: %.loc4_20.1: type = splice_block %.loc4_20.3 [symbolic = %Self.as_type.loc4_20.1 (constants.%Self.as_type)] {
  133. // CHECK:STDOUT: %.loc4_20.2: @Convert.%ImplicitAs.type (%ImplicitAs.type.07f) = specific_constant @ImplicitAs.%Self.1, @ImplicitAs(constants.%Dest) [symbolic = %Self (constants.%Self)]
  134. // CHECK:STDOUT: %Self.ref: @Convert.%ImplicitAs.type (%ImplicitAs.type.07f) = name_ref Self, %.loc4_20.2 [symbolic = %Self (constants.%Self)]
  135. // CHECK:STDOUT: %Self.as_type.loc4_20.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc4_20.1 (constants.%Self.as_type)]
  136. // CHECK:STDOUT: %.loc4_20.3: type = converted %Self.ref, %Self.as_type.loc4_20.2 [symbolic = %Self.as_type.loc4_20.1 (constants.%Self.as_type)]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: %self: @Convert.%Self.as_type.loc4_20.1 (%Self.as_type) = bind_name self, %self.param
  139. // CHECK:STDOUT: %return.param: ref @Convert.%Dest (%Dest) = out_param call_param1
  140. // CHECK:STDOUT: %return: ref @Convert.%Dest (%Dest) = return_slot %return.param
  141. // CHECK:STDOUT: }
  142. // CHECK:STDOUT: %assoc0.loc4_35.1: @ImplicitAs.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type) = assoc_entity element0, %Convert.decl [symbolic = %assoc0.loc4_35.2 (constants.%assoc0)]
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: !members:
  145. // CHECK:STDOUT: .Self = %Self.1
  146. // CHECK:STDOUT: .Dest = <poisoned>
  147. // CHECK:STDOUT: .Convert = %assoc0.loc4_35.1
  148. // CHECK:STDOUT: witness = (%Convert.decl)
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: generic fn @Convert(@ImplicitAs.%Dest.loc3_22.1: type, @ImplicitAs.%Self.1: @ImplicitAs.%ImplicitAs.type (%ImplicitAs.type.07f)) {
  153. // CHECK:STDOUT: %Dest: type = bind_symbolic_name Dest, 0 [symbolic = %Dest (constants.%Dest)]
  154. // CHECK:STDOUT: %ImplicitAs.type: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic = %ImplicitAs.type (constants.%ImplicitAs.type.07f)]
  155. // CHECK:STDOUT: %Self: %ImplicitAs.type.07f = bind_symbolic_name Self, 1 [symbolic = %Self (constants.%Self)]
  156. // CHECK:STDOUT: %Self.as_type.loc4_20.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc4_20.1 (constants.%Self.as_type)]
  157. // CHECK:STDOUT:
  158. // CHECK:STDOUT: fn[%self.param_patt: @Convert.%Self.as_type.loc4_20.1 (%Self.as_type)]() -> @Convert.%Dest (%Dest);
  159. // CHECK:STDOUT: }
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: specific @ImplicitAs(constants.%Dest) {
  162. // CHECK:STDOUT: %Dest.loc3_22.2 => constants.%Dest
  163. // CHECK:STDOUT: %Dest.patt.loc3_22.2 => constants.%Dest
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT:
  166. // CHECK:STDOUT: specific @Convert(constants.%Dest, constants.%Self) {
  167. // CHECK:STDOUT: %Dest => constants.%Dest
  168. // CHECK:STDOUT: %ImplicitAs.type => constants.%ImplicitAs.type.07f
  169. // CHECK:STDOUT: %Self => constants.%Self
  170. // CHECK:STDOUT: %Self.as_type.loc4_20.1 => constants.%Self.as_type
  171. // CHECK:STDOUT: }
  172. // CHECK:STDOUT:
  173. // CHECK:STDOUT: specific @ImplicitAs(@Convert.%Dest) {}
  174. // CHECK:STDOUT:
  175. // CHECK:STDOUT: specific @ImplicitAs(%Dest.loc3_22.2) {}
  176. // CHECK:STDOUT:
  177. // CHECK:STDOUT: --- fail_todo_non-instance_success.carbon
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: constants {
  180. // CHECK:STDOUT: %NonInstance1.type: type = facet_type <@NonInstance1> [concrete]
  181. // CHECK:STDOUT: %Self: %NonInstance1.type = bind_symbolic_name Self, 0 [symbolic]
  182. // CHECK:STDOUT: %F1.type.163: type = fn_type @F1.1 [concrete]
  183. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  184. // CHECK:STDOUT: %F1.b1f: %F1.type.163 = struct_value () [concrete]
  185. // CHECK:STDOUT: %NonInstance1.assoc_type: type = assoc_entity_type %NonInstance1.type [concrete]
  186. // CHECK:STDOUT: %assoc0: %NonInstance1.assoc_type = assoc_entity element0, @NonInstance1.%F1.decl [concrete]
  187. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_tuple.type} [concrete]
  188. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F1.decl) [concrete]
  189. // CHECK:STDOUT: %F1.type.d4a: type = fn_type @F1.2 [concrete]
  190. // CHECK:STDOUT: %F1.c75: %F1.type.d4a = struct_value () [concrete]
  191. // CHECK:STDOUT: %NonInstance1.facet: %NonInstance1.type = facet_value %struct_type.a, %impl_witness [concrete]
  192. // CHECK:STDOUT: %NonInstanceCall1.type: type = fn_type @NonInstanceCall1 [concrete]
  193. // CHECK:STDOUT: %NonInstanceCall1: %NonInstanceCall1.type = struct_value () [concrete]
  194. // CHECK:STDOUT: }
  195. // CHECK:STDOUT:
  196. // CHECK:STDOUT: file {
  197. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  198. // CHECK:STDOUT: .NonInstance1 = %NonInstance1.decl
  199. // CHECK:STDOUT: .NonInstanceCall1 = %NonInstanceCall1.decl
  200. // CHECK:STDOUT: }
  201. // CHECK:STDOUT: %NonInstance1.decl: type = interface_decl @NonInstance1 [concrete = constants.%NonInstance1.type] {} {}
  202. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  203. // CHECK:STDOUT: %.loc7_12.1: %empty_tuple.type = tuple_literal ()
  204. // CHECK:STDOUT: %.loc7_12.2: type = converted %.loc7_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  205. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_tuple.type} [concrete = constants.%struct_type.a]
  206. // CHECK:STDOUT: %NonInstance1.ref: type = name_ref NonInstance1, file.%NonInstance1.decl [concrete = constants.%NonInstance1.type]
  207. // CHECK:STDOUT: }
  208. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F1.decl) [concrete = constants.%impl_witness]
  209. // CHECK:STDOUT: %NonInstanceCall1.decl: %NonInstanceCall1.type = fn_decl @NonInstanceCall1 [concrete = constants.%NonInstanceCall1] {} {}
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: interface @NonInstance1 {
  213. // CHECK:STDOUT: %Self: %NonInstance1.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  214. // CHECK:STDOUT: %F1.decl: %F1.type.163 = fn_decl @F1.1 [concrete = constants.%F1.b1f] {} {}
  215. // CHECK:STDOUT: %assoc0: %NonInstance1.assoc_type = assoc_entity element0, %F1.decl [concrete = constants.%assoc0]
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: !members:
  218. // CHECK:STDOUT: .Self = %Self
  219. // CHECK:STDOUT: .F1 = %assoc0
  220. // CHECK:STDOUT: witness = (%F1.decl)
  221. // CHECK:STDOUT: }
  222. // CHECK:STDOUT:
  223. // CHECK:STDOUT: impl @impl: %struct_type.a as %NonInstance1.ref {
  224. // CHECK:STDOUT: %F1.decl: %F1.type.d4a = fn_decl @F1.2 [concrete = constants.%F1.c75] {} {}
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: !members:
  227. // CHECK:STDOUT: .F1 = %F1.decl
  228. // CHECK:STDOUT: witness = file.%impl_witness
  229. // CHECK:STDOUT: }
  230. // CHECK:STDOUT:
  231. // CHECK:STDOUT: generic fn @F1.1(@NonInstance1.%Self: %NonInstance1.type) {
  232. // CHECK:STDOUT: fn();
  233. // CHECK:STDOUT: }
  234. // CHECK:STDOUT:
  235. // CHECK:STDOUT: fn @F1.2() {
  236. // CHECK:STDOUT: !entry:
  237. // CHECK:STDOUT: return
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: fn @NonInstanceCall1() {
  241. // CHECK:STDOUT: !entry:
  242. // CHECK:STDOUT: %.loc16_9.1: %empty_tuple.type = tuple_literal ()
  243. // CHECK:STDOUT: %.loc16_9.2: type = converted %.loc16_9.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  244. // CHECK:STDOUT: %struct_type.a: type = struct_type {.a: %empty_tuple.type} [concrete = constants.%struct_type.a]
  245. // CHECK:STDOUT: %NonInstance1.ref: type = name_ref NonInstance1, file.%NonInstance1.decl [concrete = constants.%NonInstance1.type]
  246. // CHECK:STDOUT: %F1.ref: %NonInstance1.assoc_type = name_ref F1, @NonInstance1.%assoc0 [concrete = constants.%assoc0]
  247. // CHECK:STDOUT: return
  248. // CHECK:STDOUT: }
  249. // CHECK:STDOUT:
  250. // CHECK:STDOUT: specific @F1.1(constants.%Self) {}
  251. // CHECK:STDOUT:
  252. // CHECK:STDOUT: specific @F1.1(constants.%NonInstance1.facet) {}
  253. // CHECK:STDOUT:
  254. // CHECK:STDOUT: --- todo_fail_non-instance.carbon
  255. // CHECK:STDOUT:
  256. // CHECK:STDOUT: constants {
  257. // CHECK:STDOUT: %NonInstance2.type: type = facet_type <@NonInstance2> [concrete]
  258. // CHECK:STDOUT: %Self: %NonInstance2.type = bind_symbolic_name Self, 0 [symbolic]
  259. // CHECK:STDOUT: %F2.type.608: type = fn_type @F2.1 [concrete]
  260. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  261. // CHECK:STDOUT: %F2.86a: %F2.type.608 = struct_value () [concrete]
  262. // CHECK:STDOUT: %NonInstance2.assoc_type: type = assoc_entity_type %NonInstance2.type [concrete]
  263. // CHECK:STDOUT: %assoc0: %NonInstance2.assoc_type = assoc_entity element0, @NonInstance2.%F2.decl [concrete]
  264. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_tuple.type} [concrete]
  265. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F2.decl) [concrete]
  266. // CHECK:STDOUT: %F2.type.1ec: type = fn_type @F2.2 [concrete]
  267. // CHECK:STDOUT: %F2.941: %F2.type.1ec = struct_value () [concrete]
  268. // CHECK:STDOUT: %NonInstance2.facet: %NonInstance2.type = facet_value %struct_type.b, %impl_witness [concrete]
  269. // CHECK:STDOUT: %NonInstanceCall2.type: type = fn_type @NonInstanceCall2 [concrete]
  270. // CHECK:STDOUT: %NonInstanceCall2: %NonInstanceCall2.type = struct_value () [concrete]
  271. // CHECK:STDOUT: %.3a1: type = fn_type_with_self_type %F2.type.608, %NonInstance2.facet [concrete]
  272. // CHECK:STDOUT: }
  273. // CHECK:STDOUT:
  274. // CHECK:STDOUT: imports {
  275. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  276. // CHECK:STDOUT: import Core//default
  277. // CHECK:STDOUT: }
  278. // CHECK:STDOUT: }
  279. // CHECK:STDOUT:
  280. // CHECK:STDOUT: file {
  281. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  282. // CHECK:STDOUT: .Core = imports.%Core
  283. // CHECK:STDOUT: .NonInstance2 = %NonInstance2.decl
  284. // CHECK:STDOUT: .NonInstanceCall2 = %NonInstanceCall2.decl
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT: %Core.import = import Core
  287. // CHECK:STDOUT: %NonInstance2.decl: type = interface_decl @NonInstance2 [concrete = constants.%NonInstance2.type] {} {}
  288. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  289. // CHECK:STDOUT: %.loc9_12.1: %empty_tuple.type = tuple_literal ()
  290. // CHECK:STDOUT: %.loc9_12.2: type = converted %.loc9_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  291. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_tuple.type} [concrete = constants.%struct_type.b]
  292. // CHECK:STDOUT: %NonInstance2.ref: type = name_ref NonInstance2, file.%NonInstance2.decl [concrete = constants.%NonInstance2.type]
  293. // CHECK:STDOUT: }
  294. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F2.decl) [concrete = constants.%impl_witness]
  295. // CHECK:STDOUT: %NonInstanceCall2.decl: %NonInstanceCall2.type = fn_decl @NonInstanceCall2 [concrete = constants.%NonInstanceCall2] {
  296. // CHECK:STDOUT: %n.patt: %struct_type.b = binding_pattern n
  297. // CHECK:STDOUT: %n.param_patt: %struct_type.b = value_param_pattern %n.patt, call_param0
  298. // CHECK:STDOUT: } {
  299. // CHECK:STDOUT: %n.param: %struct_type.b = value_param call_param0
  300. // CHECK:STDOUT: %.loc13_31: type = splice_block %struct_type.b [concrete = constants.%struct_type.b] {
  301. // CHECK:STDOUT: %.loc13_30.1: %empty_tuple.type = tuple_literal ()
  302. // CHECK:STDOUT: %.loc13_30.2: type = converted %.loc13_30.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  303. // CHECK:STDOUT: %struct_type.b: type = struct_type {.b: %empty_tuple.type} [concrete = constants.%struct_type.b]
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT: %n: %struct_type.b = bind_name n, %n.param
  306. // CHECK:STDOUT: }
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: interface @NonInstance2 {
  310. // CHECK:STDOUT: %Self: %NonInstance2.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  311. // CHECK:STDOUT: %F2.decl: %F2.type.608 = fn_decl @F2.1 [concrete = constants.%F2.86a] {} {}
  312. // CHECK:STDOUT: %assoc0: %NonInstance2.assoc_type = assoc_entity element0, %F2.decl [concrete = constants.%assoc0]
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: !members:
  315. // CHECK:STDOUT: .Self = %Self
  316. // CHECK:STDOUT: .F2 = %assoc0
  317. // CHECK:STDOUT: witness = (%F2.decl)
  318. // CHECK:STDOUT: }
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: impl @impl: %struct_type.b as %NonInstance2.ref {
  321. // CHECK:STDOUT: %F2.decl: %F2.type.1ec = fn_decl @F2.2 [concrete = constants.%F2.941] {} {}
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: !members:
  324. // CHECK:STDOUT: .F2 = %F2.decl
  325. // CHECK:STDOUT: witness = file.%impl_witness
  326. // CHECK:STDOUT: }
  327. // CHECK:STDOUT:
  328. // CHECK:STDOUT: generic fn @F2.1(@NonInstance2.%Self: %NonInstance2.type) {
  329. // CHECK:STDOUT: fn();
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT:
  332. // CHECK:STDOUT: fn @F2.2() {
  333. // CHECK:STDOUT: !entry:
  334. // CHECK:STDOUT: return
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: fn @NonInstanceCall2(%n.param_patt: %struct_type.b) {
  338. // CHECK:STDOUT: !entry:
  339. // CHECK:STDOUT: %n.ref: %struct_type.b = name_ref n, %n
  340. // CHECK:STDOUT: %NonInstance2.ref: type = name_ref NonInstance2, file.%NonInstance2.decl [concrete = constants.%NonInstance2.type]
  341. // CHECK:STDOUT: %F2.ref: %NonInstance2.assoc_type = name_ref F2, @NonInstance2.%assoc0 [concrete = constants.%assoc0]
  342. // CHECK:STDOUT: %impl.elem0: %.3a1 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%F2.941]
  343. // CHECK:STDOUT: %F2.call: init %empty_tuple.type = call %impl.elem0()
  344. // CHECK:STDOUT: return
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: specific @F2.1(constants.%Self) {}
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: specific @F2.1(constants.%NonInstance2.facet) {}
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: --- todo_fail_non-instance_indirect.carbon
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: constants {
  354. // CHECK:STDOUT: %NonInstance3.type: type = facet_type <@NonInstance3> [concrete]
  355. // CHECK:STDOUT: %Self: %NonInstance3.type = bind_symbolic_name Self, 0 [symbolic]
  356. // CHECK:STDOUT: %F3.type.ee4: type = fn_type @F3.1 [concrete]
  357. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  358. // CHECK:STDOUT: %F3.752: %F3.type.ee4 = struct_value () [concrete]
  359. // CHECK:STDOUT: %NonInstance3.assoc_type: type = assoc_entity_type %NonInstance3.type [concrete]
  360. // CHECK:STDOUT: %assoc0: %NonInstance3.assoc_type = assoc_entity element0, @NonInstance3.%F3.decl [concrete]
  361. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %empty_tuple.type} [concrete]
  362. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F3.decl) [concrete]
  363. // CHECK:STDOUT: %F3.type.1c2: type = fn_type @F3.2 [concrete]
  364. // CHECK:STDOUT: %F3.1d3: %F3.type.1c2 = struct_value () [concrete]
  365. // CHECK:STDOUT: %NonInstance3.facet: %NonInstance3.type = facet_value %struct_type.c, %impl_witness [concrete]
  366. // CHECK:STDOUT: %ptr: type = ptr_type %struct_type.c [concrete]
  367. // CHECK:STDOUT: %NonInstanceCallIndirect.type: type = fn_type @NonInstanceCallIndirect [concrete]
  368. // CHECK:STDOUT: %NonInstanceCallIndirect: %NonInstanceCallIndirect.type = struct_value () [concrete]
  369. // CHECK:STDOUT: %.f98: type = fn_type_with_self_type %F3.type.ee4, %NonInstance3.facet [concrete]
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: imports {
  373. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  374. // CHECK:STDOUT: import Core//default
  375. // CHECK:STDOUT: }
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: file {
  379. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  380. // CHECK:STDOUT: .Core = imports.%Core
  381. // CHECK:STDOUT: .NonInstance3 = %NonInstance3.decl
  382. // CHECK:STDOUT: .NonInstanceCallIndirect = %NonInstanceCallIndirect.decl
  383. // CHECK:STDOUT: }
  384. // CHECK:STDOUT: %Core.import = import Core
  385. // CHECK:STDOUT: %NonInstance3.decl: type = interface_decl @NonInstance3 [concrete = constants.%NonInstance3.type] {} {}
  386. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  387. // CHECK:STDOUT: %.loc9_12.1: %empty_tuple.type = tuple_literal ()
  388. // CHECK:STDOUT: %.loc9_12.2: type = converted %.loc9_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  389. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %empty_tuple.type} [concrete = constants.%struct_type.c]
  390. // CHECK:STDOUT: %NonInstance3.ref: type = name_ref NonInstance3, file.%NonInstance3.decl [concrete = constants.%NonInstance3.type]
  391. // CHECK:STDOUT: }
  392. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%F3.decl) [concrete = constants.%impl_witness]
  393. // CHECK:STDOUT: %NonInstanceCallIndirect.decl: %NonInstanceCallIndirect.type = fn_decl @NonInstanceCallIndirect [concrete = constants.%NonInstanceCallIndirect] {
  394. // CHECK:STDOUT: %p.patt: %ptr = binding_pattern p
  395. // CHECK:STDOUT: %p.param_patt: %ptr = value_param_pattern %p.patt, call_param0
  396. // CHECK:STDOUT: } {
  397. // CHECK:STDOUT: %p.param: %ptr = value_param call_param0
  398. // CHECK:STDOUT: %.loc13_39: type = splice_block %ptr [concrete = constants.%ptr] {
  399. // CHECK:STDOUT: %.loc13_37.1: %empty_tuple.type = tuple_literal ()
  400. // CHECK:STDOUT: %.loc13_37.2: type = converted %.loc13_37.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  401. // CHECK:STDOUT: %struct_type.c: type = struct_type {.c: %empty_tuple.type} [concrete = constants.%struct_type.c]
  402. // CHECK:STDOUT: %ptr: type = ptr_type %struct_type.c [concrete = constants.%ptr]
  403. // CHECK:STDOUT: }
  404. // CHECK:STDOUT: %p: %ptr = bind_name p, %p.param
  405. // CHECK:STDOUT: }
  406. // CHECK:STDOUT: }
  407. // CHECK:STDOUT:
  408. // CHECK:STDOUT: interface @NonInstance3 {
  409. // CHECK:STDOUT: %Self: %NonInstance3.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  410. // CHECK:STDOUT: %F3.decl: %F3.type.ee4 = fn_decl @F3.1 [concrete = constants.%F3.752] {} {}
  411. // CHECK:STDOUT: %assoc0: %NonInstance3.assoc_type = assoc_entity element0, %F3.decl [concrete = constants.%assoc0]
  412. // CHECK:STDOUT:
  413. // CHECK:STDOUT: !members:
  414. // CHECK:STDOUT: .Self = %Self
  415. // CHECK:STDOUT: .F3 = %assoc0
  416. // CHECK:STDOUT: witness = (%F3.decl)
  417. // CHECK:STDOUT: }
  418. // CHECK:STDOUT:
  419. // CHECK:STDOUT: impl @impl: %struct_type.c as %NonInstance3.ref {
  420. // CHECK:STDOUT: %F3.decl: %F3.type.1c2 = fn_decl @F3.2 [concrete = constants.%F3.1d3] {} {}
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: !members:
  423. // CHECK:STDOUT: .F3 = %F3.decl
  424. // CHECK:STDOUT: witness = file.%impl_witness
  425. // CHECK:STDOUT: }
  426. // CHECK:STDOUT:
  427. // CHECK:STDOUT: generic fn @F3.1(@NonInstance3.%Self: %NonInstance3.type) {
  428. // CHECK:STDOUT: fn();
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: fn @F3.2() {
  432. // CHECK:STDOUT: !entry:
  433. // CHECK:STDOUT: return
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: fn @NonInstanceCallIndirect(%p.param_patt: %ptr) {
  437. // CHECK:STDOUT: !entry:
  438. // CHECK:STDOUT: %p.ref: %ptr = name_ref p, %p
  439. // CHECK:STDOUT: %NonInstance3.ref: type = name_ref NonInstance3, file.%NonInstance3.decl [concrete = constants.%NonInstance3.type]
  440. // CHECK:STDOUT: %F3.ref: %NonInstance3.assoc_type = name_ref F3, @NonInstance3.%assoc0 [concrete = constants.%assoc0]
  441. // CHECK:STDOUT: %.loc14: ref %struct_type.c = deref %p.ref
  442. // CHECK:STDOUT: %impl.elem0: %.f98 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%F3.1d3]
  443. // CHECK:STDOUT: %F3.call: init %empty_tuple.type = call %impl.elem0()
  444. // CHECK:STDOUT: return
  445. // CHECK:STDOUT: }
  446. // CHECK:STDOUT:
  447. // CHECK:STDOUT: specific @F3.1(constants.%Self) {}
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: specific @F3.1(constants.%NonInstance3.facet) {}
  450. // CHECK:STDOUT:
  451. // CHECK:STDOUT: --- instance_success.carbon
  452. // CHECK:STDOUT:
  453. // CHECK:STDOUT: constants {
  454. // CHECK:STDOUT: %Instance1.type: type = facet_type <@Instance1> [concrete]
  455. // CHECK:STDOUT: %Self: %Instance1.type = bind_symbolic_name Self, 0 [symbolic]
  456. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  457. // CHECK:STDOUT: %G1.type.cde: type = fn_type @G1.1 [concrete]
  458. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  459. // CHECK:STDOUT: %G1.79a: %G1.type.cde = struct_value () [concrete]
  460. // CHECK:STDOUT: %Instance1.assoc_type: type = assoc_entity_type %Instance1.type [concrete]
  461. // CHECK:STDOUT: %assoc0: %Instance1.assoc_type = assoc_entity element0, @Instance1.%G1.decl [concrete]
  462. // CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %empty_tuple.type} [concrete]
  463. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%G1.decl) [concrete]
  464. // CHECK:STDOUT: %G1.type.c50: type = fn_type @G1.2 [concrete]
  465. // CHECK:STDOUT: %G1.fee: %G1.type.c50 = struct_value () [concrete]
  466. // CHECK:STDOUT: %Instance1.facet: %Instance1.type = facet_value %struct_type.d, %impl_witness [concrete]
  467. // CHECK:STDOUT: %InstanceCall.type: type = fn_type @InstanceCall [concrete]
  468. // CHECK:STDOUT: %InstanceCall: %InstanceCall.type = struct_value () [concrete]
  469. // CHECK:STDOUT: %.4d6: type = fn_type_with_self_type %G1.type.cde, %Instance1.facet [concrete]
  470. // CHECK:STDOUT: %ptr: type = ptr_type %struct_type.d [concrete]
  471. // CHECK:STDOUT: %InstanceCallIndirect.type: type = fn_type @InstanceCallIndirect [concrete]
  472. // CHECK:STDOUT: %InstanceCallIndirect: %InstanceCallIndirect.type = struct_value () [concrete]
  473. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  474. // CHECK:STDOUT: %struct: %struct_type.d = struct_value (%empty_tuple) [concrete]
  475. // CHECK:STDOUT: }
  476. // CHECK:STDOUT:
  477. // CHECK:STDOUT: file {
  478. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  479. // CHECK:STDOUT: .Instance1 = %Instance1.decl
  480. // CHECK:STDOUT: .InstanceCall = %InstanceCall.decl
  481. // CHECK:STDOUT: .InstanceCallIndirect = %InstanceCallIndirect.decl
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT: %Instance1.decl: type = interface_decl @Instance1 [concrete = constants.%Instance1.type] {} {}
  484. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  485. // CHECK:STDOUT: %.loc7_12.1: %empty_tuple.type = tuple_literal ()
  486. // CHECK:STDOUT: %.loc7_12.2: type = converted %.loc7_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  487. // CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %empty_tuple.type} [concrete = constants.%struct_type.d]
  488. // CHECK:STDOUT: %Instance1.ref: type = name_ref Instance1, file.%Instance1.decl [concrete = constants.%Instance1.type]
  489. // CHECK:STDOUT: }
  490. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%G1.decl) [concrete = constants.%impl_witness]
  491. // CHECK:STDOUT: %InstanceCall.decl: %InstanceCall.type = fn_decl @InstanceCall [concrete = constants.%InstanceCall] {
  492. // CHECK:STDOUT: %n.patt: %struct_type.d = binding_pattern n
  493. // CHECK:STDOUT: %n.param_patt: %struct_type.d = value_param_pattern %n.patt, call_param0
  494. // CHECK:STDOUT: } {
  495. // CHECK:STDOUT: %n.param: %struct_type.d = value_param call_param0
  496. // CHECK:STDOUT: %.loc11_27: type = splice_block %struct_type.d [concrete = constants.%struct_type.d] {
  497. // CHECK:STDOUT: %.loc11_26.1: %empty_tuple.type = tuple_literal ()
  498. // CHECK:STDOUT: %.loc11_26.2: type = converted %.loc11_26.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  499. // CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %empty_tuple.type} [concrete = constants.%struct_type.d]
  500. // CHECK:STDOUT: }
  501. // CHECK:STDOUT: %n: %struct_type.d = bind_name n, %n.param
  502. // CHECK:STDOUT: }
  503. // CHECK:STDOUT: %InstanceCallIndirect.decl: %InstanceCallIndirect.type = fn_decl @InstanceCallIndirect [concrete = constants.%InstanceCallIndirect] {
  504. // CHECK:STDOUT: %p.patt: %ptr = binding_pattern p
  505. // CHECK:STDOUT: %p.param_patt: %ptr = value_param_pattern %p.patt, call_param0
  506. // CHECK:STDOUT: } {
  507. // CHECK:STDOUT: %p.param: %ptr = value_param call_param0
  508. // CHECK:STDOUT: %.loc15_36: type = splice_block %ptr [concrete = constants.%ptr] {
  509. // CHECK:STDOUT: %.loc15_34.1: %empty_tuple.type = tuple_literal ()
  510. // CHECK:STDOUT: %.loc15_34.2: type = converted %.loc15_34.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  511. // CHECK:STDOUT: %struct_type.d: type = struct_type {.d: %empty_tuple.type} [concrete = constants.%struct_type.d]
  512. // CHECK:STDOUT: %ptr: type = ptr_type %struct_type.d [concrete = constants.%ptr]
  513. // CHECK:STDOUT: }
  514. // CHECK:STDOUT: %p: %ptr = bind_name p, %p.param
  515. // CHECK:STDOUT: }
  516. // CHECK:STDOUT: }
  517. // CHECK:STDOUT:
  518. // CHECK:STDOUT: interface @Instance1 {
  519. // CHECK:STDOUT: %Self: %Instance1.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  520. // CHECK:STDOUT: %G1.decl: %G1.type.cde = fn_decl @G1.1 [concrete = constants.%G1.79a] {
  521. // CHECK:STDOUT: %self.patt: @G1.1.%Self.as_type.loc4_15.1 (%Self.as_type) = binding_pattern self
  522. // CHECK:STDOUT: %self.param_patt: @G1.1.%Self.as_type.loc4_15.1 (%Self.as_type) = value_param_pattern %self.patt, call_param0
  523. // CHECK:STDOUT: } {
  524. // CHECK:STDOUT: %self.param: @G1.1.%Self.as_type.loc4_15.1 (%Self.as_type) = value_param call_param0
  525. // CHECK:STDOUT: %.loc4_15.1: type = splice_block %.loc4_15.2 [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)] {
  526. // CHECK:STDOUT: %Self.ref: %Instance1.type = name_ref Self, @Instance1.%Self [symbolic = %Self (constants.%Self)]
  527. // CHECK:STDOUT: %Self.as_type.loc4_15.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)]
  528. // CHECK:STDOUT: %.loc4_15.2: type = converted %Self.ref, %Self.as_type.loc4_15.2 [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)]
  529. // CHECK:STDOUT: }
  530. // CHECK:STDOUT: %self: @G1.1.%Self.as_type.loc4_15.1 (%Self.as_type) = bind_name self, %self.param
  531. // CHECK:STDOUT: }
  532. // CHECK:STDOUT: %assoc0: %Instance1.assoc_type = assoc_entity element0, %G1.decl [concrete = constants.%assoc0]
  533. // CHECK:STDOUT:
  534. // CHECK:STDOUT: !members:
  535. // CHECK:STDOUT: .Self = %Self
  536. // CHECK:STDOUT: .G1 = %assoc0
  537. // CHECK:STDOUT: witness = (%G1.decl)
  538. // CHECK:STDOUT: }
  539. // CHECK:STDOUT:
  540. // CHECK:STDOUT: impl @impl: %struct_type.d as %Instance1.ref {
  541. // CHECK:STDOUT: %G1.decl: %G1.type.c50 = fn_decl @G1.2 [concrete = constants.%G1.fee] {
  542. // CHECK:STDOUT: %self.patt: %struct_type.d = binding_pattern self
  543. // CHECK:STDOUT: %self.param_patt: %struct_type.d = value_param_pattern %self.patt, call_param0
  544. // CHECK:STDOUT: } {
  545. // CHECK:STDOUT: %self.param: %struct_type.d = value_param call_param0
  546. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%struct_type.d [concrete = constants.%struct_type.d]
  547. // CHECK:STDOUT: %self: %struct_type.d = bind_name self, %self.param
  548. // CHECK:STDOUT: }
  549. // CHECK:STDOUT:
  550. // CHECK:STDOUT: !members:
  551. // CHECK:STDOUT: .G1 = %G1.decl
  552. // CHECK:STDOUT: witness = file.%impl_witness
  553. // CHECK:STDOUT: }
  554. // CHECK:STDOUT:
  555. // CHECK:STDOUT: generic fn @G1.1(@Instance1.%Self: %Instance1.type) {
  556. // CHECK:STDOUT: %Self: %Instance1.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  557. // CHECK:STDOUT: %Self.as_type.loc4_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)]
  558. // CHECK:STDOUT:
  559. // CHECK:STDOUT: fn[%self.param_patt: @G1.1.%Self.as_type.loc4_15.1 (%Self.as_type)]();
  560. // CHECK:STDOUT: }
  561. // CHECK:STDOUT:
  562. // CHECK:STDOUT: fn @G1.2[%self.param_patt: %struct_type.d]() {
  563. // CHECK:STDOUT: !entry:
  564. // CHECK:STDOUT: return
  565. // CHECK:STDOUT: }
  566. // CHECK:STDOUT:
  567. // CHECK:STDOUT: fn @InstanceCall(%n.param_patt: %struct_type.d) {
  568. // CHECK:STDOUT: !entry:
  569. // CHECK:STDOUT: %n.ref: %struct_type.d = name_ref n, %n
  570. // CHECK:STDOUT: %Instance1.ref: type = name_ref Instance1, file.%Instance1.decl [concrete = constants.%Instance1.type]
  571. // CHECK:STDOUT: %G1.ref: %Instance1.assoc_type = name_ref G1, @Instance1.%assoc0 [concrete = constants.%assoc0]
  572. // CHECK:STDOUT: %impl.elem0: %.4d6 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%G1.fee]
  573. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %n.ref, %impl.elem0
  574. // CHECK:STDOUT: %G1.call: init %empty_tuple.type = call %bound_method(%n.ref)
  575. // CHECK:STDOUT: return
  576. // CHECK:STDOUT: }
  577. // CHECK:STDOUT:
  578. // CHECK:STDOUT: fn @InstanceCallIndirect(%p.param_patt: %ptr) {
  579. // CHECK:STDOUT: !entry:
  580. // CHECK:STDOUT: %p.ref: %ptr = name_ref p, %p
  581. // CHECK:STDOUT: %Instance1.ref: type = name_ref Instance1, file.%Instance1.decl [concrete = constants.%Instance1.type]
  582. // CHECK:STDOUT: %G1.ref: %Instance1.assoc_type = name_ref G1, @Instance1.%assoc0 [concrete = constants.%assoc0]
  583. // CHECK:STDOUT: %.loc16_4.1: ref %struct_type.d = deref %p.ref
  584. // CHECK:STDOUT: %impl.elem0: %.4d6 = impl_witness_access constants.%impl_witness, element0 [concrete = constants.%G1.fee]
  585. // CHECK:STDOUT: %bound_method: <bound method> = bound_method %.loc16_4.1, %impl.elem0
  586. // CHECK:STDOUT: %.loc16_4.2: ref %empty_tuple.type = struct_access %.loc16_4.1, element0
  587. // CHECK:STDOUT: %tuple: %empty_tuple.type = tuple_value () [concrete = constants.%empty_tuple]
  588. // CHECK:STDOUT: %.loc16_4.3: %empty_tuple.type = converted %.loc16_4.2, %tuple [concrete = constants.%empty_tuple]
  589. // CHECK:STDOUT: %struct: %struct_type.d = struct_value (%.loc16_4.3) [concrete = constants.%struct]
  590. // CHECK:STDOUT: %.loc16_4.4: %struct_type.d = converted %.loc16_4.1, %struct [concrete = constants.%struct]
  591. // CHECK:STDOUT: %G1.call: init %empty_tuple.type = call %bound_method(%.loc16_4.4)
  592. // CHECK:STDOUT: return
  593. // CHECK:STDOUT: }
  594. // CHECK:STDOUT:
  595. // CHECK:STDOUT: specific @G1.1(constants.%Self) {
  596. // CHECK:STDOUT: %Self => constants.%Self
  597. // CHECK:STDOUT: %Self.as_type.loc4_15.1 => constants.%Self.as_type
  598. // CHECK:STDOUT: }
  599. // CHECK:STDOUT:
  600. // CHECK:STDOUT: specific @G1.1(constants.%Instance1.facet) {
  601. // CHECK:STDOUT: %Self => constants.%Instance1.facet
  602. // CHECK:STDOUT: %Self.as_type.loc4_15.1 => constants.%struct_type.d
  603. // CHECK:STDOUT: }
  604. // CHECK:STDOUT:
  605. // CHECK:STDOUT: --- fail_instance.carbon
  606. // CHECK:STDOUT:
  607. // CHECK:STDOUT: constants {
  608. // CHECK:STDOUT: %Instance2.type: type = facet_type <@Instance2> [concrete]
  609. // CHECK:STDOUT: %Self: %Instance2.type = bind_symbolic_name Self, 0 [symbolic]
  610. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  611. // CHECK:STDOUT: %G2.type.aa7: type = fn_type @G2.1 [concrete]
  612. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  613. // CHECK:STDOUT: %G2.588: %G2.type.aa7 = struct_value () [concrete]
  614. // CHECK:STDOUT: %Instance2.assoc_type: type = assoc_entity_type %Instance2.type [concrete]
  615. // CHECK:STDOUT: %assoc0: %Instance2.assoc_type = assoc_entity element0, @Instance2.%G2.decl [concrete]
  616. // CHECK:STDOUT: %struct_type.e: type = struct_type {.e: %empty_tuple.type} [concrete]
  617. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%G2.decl) [concrete]
  618. // CHECK:STDOUT: %G2.type.50c: type = fn_type @G2.2 [concrete]
  619. // CHECK:STDOUT: %G2.707: %G2.type.50c = struct_value () [concrete]
  620. // CHECK:STDOUT: %Instance2.facet: %Instance2.type = facet_value %struct_type.e, %impl_witness [concrete]
  621. // CHECK:STDOUT: %InstanceCallFail.type: type = fn_type @InstanceCallFail [concrete]
  622. // CHECK:STDOUT: %InstanceCallFail: %InstanceCallFail.type = struct_value () [concrete]
  623. // CHECK:STDOUT: }
  624. // CHECK:STDOUT:
  625. // CHECK:STDOUT: file {
  626. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  627. // CHECK:STDOUT: .Instance2 = %Instance2.decl
  628. // CHECK:STDOUT: .InstanceCallFail = %InstanceCallFail.decl
  629. // CHECK:STDOUT: }
  630. // CHECK:STDOUT: %Instance2.decl: type = interface_decl @Instance2 [concrete = constants.%Instance2.type] {} {}
  631. // CHECK:STDOUT: impl_decl @impl [concrete] {} {
  632. // CHECK:STDOUT: %.loc7_12.1: %empty_tuple.type = tuple_literal ()
  633. // CHECK:STDOUT: %.loc7_12.2: type = converted %.loc7_12.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  634. // CHECK:STDOUT: %struct_type.e: type = struct_type {.e: %empty_tuple.type} [concrete = constants.%struct_type.e]
  635. // CHECK:STDOUT: %Instance2.ref: type = name_ref Instance2, file.%Instance2.decl [concrete = constants.%Instance2.type]
  636. // CHECK:STDOUT: }
  637. // CHECK:STDOUT: %impl_witness: <witness> = impl_witness (@impl.%G2.decl) [concrete = constants.%impl_witness]
  638. // CHECK:STDOUT: %InstanceCallFail.decl: %InstanceCallFail.type = fn_decl @InstanceCallFail [concrete = constants.%InstanceCallFail] {} {}
  639. // CHECK:STDOUT: }
  640. // CHECK:STDOUT:
  641. // CHECK:STDOUT: interface @Instance2 {
  642. // CHECK:STDOUT: %Self: %Instance2.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  643. // CHECK:STDOUT: %G2.decl: %G2.type.aa7 = fn_decl @G2.1 [concrete = constants.%G2.588] {
  644. // CHECK:STDOUT: %self.patt: @G2.1.%Self.as_type.loc4_15.1 (%Self.as_type) = binding_pattern self
  645. // CHECK:STDOUT: %self.param_patt: @G2.1.%Self.as_type.loc4_15.1 (%Self.as_type) = value_param_pattern %self.patt, call_param0
  646. // CHECK:STDOUT: } {
  647. // CHECK:STDOUT: %self.param: @G2.1.%Self.as_type.loc4_15.1 (%Self.as_type) = value_param call_param0
  648. // CHECK:STDOUT: %.loc4_15.1: type = splice_block %.loc4_15.2 [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)] {
  649. // CHECK:STDOUT: %Self.ref: %Instance2.type = name_ref Self, @Instance2.%Self [symbolic = %Self (constants.%Self)]
  650. // CHECK:STDOUT: %Self.as_type.loc4_15.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)]
  651. // CHECK:STDOUT: %.loc4_15.2: type = converted %Self.ref, %Self.as_type.loc4_15.2 [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)]
  652. // CHECK:STDOUT: }
  653. // CHECK:STDOUT: %self: @G2.1.%Self.as_type.loc4_15.1 (%Self.as_type) = bind_name self, %self.param
  654. // CHECK:STDOUT: }
  655. // CHECK:STDOUT: %assoc0: %Instance2.assoc_type = assoc_entity element0, %G2.decl [concrete = constants.%assoc0]
  656. // CHECK:STDOUT:
  657. // CHECK:STDOUT: !members:
  658. // CHECK:STDOUT: .Self = %Self
  659. // CHECK:STDOUT: .G2 = %assoc0
  660. // CHECK:STDOUT: witness = (%G2.decl)
  661. // CHECK:STDOUT: }
  662. // CHECK:STDOUT:
  663. // CHECK:STDOUT: impl @impl: %struct_type.e as %Instance2.ref {
  664. // CHECK:STDOUT: %G2.decl: %G2.type.50c = fn_decl @G2.2 [concrete = constants.%G2.707] {
  665. // CHECK:STDOUT: %self.patt: %struct_type.e = binding_pattern self
  666. // CHECK:STDOUT: %self.param_patt: %struct_type.e = value_param_pattern %self.patt, call_param0
  667. // CHECK:STDOUT: } {
  668. // CHECK:STDOUT: %self.param: %struct_type.e = value_param call_param0
  669. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @impl.%struct_type.e [concrete = constants.%struct_type.e]
  670. // CHECK:STDOUT: %self: %struct_type.e = bind_name self, %self.param
  671. // CHECK:STDOUT: }
  672. // CHECK:STDOUT:
  673. // CHECK:STDOUT: !members:
  674. // CHECK:STDOUT: .G2 = %G2.decl
  675. // CHECK:STDOUT: witness = file.%impl_witness
  676. // CHECK:STDOUT: }
  677. // CHECK:STDOUT:
  678. // CHECK:STDOUT: generic fn @G2.1(@Instance2.%Self: %Instance2.type) {
  679. // CHECK:STDOUT: %Self: %Instance2.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  680. // CHECK:STDOUT: %Self.as_type.loc4_15.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc4_15.1 (constants.%Self.as_type)]
  681. // CHECK:STDOUT:
  682. // CHECK:STDOUT: fn[%self.param_patt: @G2.1.%Self.as_type.loc4_15.1 (%Self.as_type)]();
  683. // CHECK:STDOUT: }
  684. // CHECK:STDOUT:
  685. // CHECK:STDOUT: fn @G2.2[%self.param_patt: %struct_type.e]() {
  686. // CHECK:STDOUT: !entry:
  687. // CHECK:STDOUT: return
  688. // CHECK:STDOUT: }
  689. // CHECK:STDOUT:
  690. // CHECK:STDOUT: fn @InstanceCallFail() {
  691. // CHECK:STDOUT: !entry:
  692. // CHECK:STDOUT: %.loc16_9.1: %empty_tuple.type = tuple_literal ()
  693. // CHECK:STDOUT: %.loc16_9.2: type = converted %.loc16_9.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  694. // CHECK:STDOUT: %struct_type.e: type = struct_type {.e: %empty_tuple.type} [concrete = constants.%struct_type.e]
  695. // CHECK:STDOUT: %Instance2.ref: type = name_ref Instance2, file.%Instance2.decl [concrete = constants.%Instance2.type]
  696. // CHECK:STDOUT: %G2.ref: %Instance2.assoc_type = name_ref G2, @Instance2.%assoc0 [concrete = constants.%assoc0]
  697. // CHECK:STDOUT: return
  698. // CHECK:STDOUT: }
  699. // CHECK:STDOUT:
  700. // CHECK:STDOUT: specific @G2.1(constants.%Self) {
  701. // CHECK:STDOUT: %Self => constants.%Self
  702. // CHECK:STDOUT: %Self.as_type.loc4_15.1 => constants.%Self.as_type
  703. // CHECK:STDOUT: }
  704. // CHECK:STDOUT:
  705. // CHECK:STDOUT: specific @G2.1(constants.%Instance2.facet) {
  706. // CHECK:STDOUT: %Self => constants.%Instance2.facet
  707. // CHECK:STDOUT: %Self.as_type.loc4_15.1 => constants.%struct_type.e
  708. // CHECK:STDOUT: }
  709. // CHECK:STDOUT: