binding_pattern.carbon 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454
  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/convert.carbon
  6. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  7. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  8. //
  9. // AUTOUPDATE
  10. // TIP: To test this file alone, run:
  11. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/deduce/binding_pattern.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/deduce/binding_pattern.carbon
  14. // --- fail_incompatible_deduce.carbon
  15. library "[[@TEST_NAME]]";
  16. class C(T:! type) {
  17. fn Create(unused value: T) {}
  18. }
  19. fn F(unused U:! type, V:! type) {
  20. // CHECK:STDERR: fail_incompatible_deduce.carbon:[[@LINE+10]]:15: error: cannot implicitly convert expression of type `{}` to `V` [ConversionFailure]
  21. // CHECK:STDERR: C(V).Create({});
  22. // CHECK:STDERR: ^~
  23. // CHECK:STDERR: fail_incompatible_deduce.carbon:[[@LINE+7]]:15: note: type `{}` does not implement interface `Core.ImplicitAs(V)` [MissingImplInMemberAccessNote]
  24. // CHECK:STDERR: C(V).Create({});
  25. // CHECK:STDERR: ^~
  26. // CHECK:STDERR: fail_incompatible_deduce.carbon:[[@LINE-10]]:20: note: initializing function parameter [InCallToFunctionParam]
  27. // CHECK:STDERR: fn Create(unused value: T) {}
  28. // CHECK:STDERR: ^~~~~~~~
  29. // CHECK:STDERR:
  30. C(V).Create({});
  31. }
  32. // --- fail_todo_compatible_deduce.carbon
  33. library "[[@TEST_NAME]]";
  34. class C(T:! type) {
  35. fn Create(unused value: T) {}
  36. }
  37. // TODO: This `where` should be sufficient to say that `{} as V` works.
  38. fn F(unused U:! type, V:! type where {} impls Core.ImplicitAs(.Self)) {
  39. // CHECK:STDERR: fail_todo_compatible_deduce.carbon:[[@LINE+10]]:15: error: cannot implicitly convert expression of type `{}` to `V` [ConversionFailure]
  40. // CHECK:STDERR: C(V).Create({});
  41. // CHECK:STDERR: ^~
  42. // CHECK:STDERR: fail_todo_compatible_deduce.carbon:[[@LINE+7]]:15: note: type `{}` does not implement interface `Core.ImplicitAs(V)` [MissingImplInMemberAccessNote]
  43. // CHECK:STDERR: C(V).Create({});
  44. // CHECK:STDERR: ^~
  45. // CHECK:STDERR: fail_todo_compatible_deduce.carbon:[[@LINE-11]]:20: note: initializing function parameter [InCallToFunctionParam]
  46. // CHECK:STDERR: fn Create(unused value: T) {}
  47. // CHECK:STDERR: ^~~~~~~~
  48. // CHECK:STDERR:
  49. C(V).Create({});
  50. }
  51. // CHECK:STDOUT: --- fail_incompatible_deduce.carbon
  52. // CHECK:STDOUT:
  53. // CHECK:STDOUT: constants {
  54. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  55. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  56. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  57. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  58. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  59. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  60. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  61. // CHECK:STDOUT: %C.5a3: type = class_type @C, @C(%T) [symbolic]
  62. // CHECK:STDOUT: %pattern_type.51d1c4.1: type = pattern_type %T [symbolic]
  63. // CHECK:STDOUT: %C.Create.type.c11: type = fn_type @C.Create, @C(%T) [symbolic]
  64. // CHECK:STDOUT: %C.Create.723: %C.Create.type.c11 = struct_value () [symbolic]
  65. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  66. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  67. // CHECK:STDOUT: %require_complete.944: <witness> = require_complete_type %T [symbolic]
  68. // CHECK:STDOUT: %U: type = symbolic_binding U, 0 [symbolic]
  69. // CHECK:STDOUT: %V: type = symbolic_binding V, 1 [symbolic]
  70. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  71. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  72. // CHECK:STDOUT: %C.ee9: type = class_type @C, @C(%V) [symbolic]
  73. // CHECK:STDOUT: %C.Create.type.c3d: type = fn_type @C.Create, @C(%V) [symbolic]
  74. // CHECK:STDOUT: %C.Create.b40: %C.Create.type.c3d = struct_value () [symbolic]
  75. // CHECK:STDOUT: %require_complete.1fc: <witness> = require_complete_type %C.ee9 [symbolic]
  76. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  77. // CHECK:STDOUT: %pattern_type.946: type = pattern_type %V [symbolic]
  78. // CHECK:STDOUT: %C.Create.specific_fn: <specific function> = specific_function %C.Create.b40, @C.Create(%V) [symbolic]
  79. // CHECK:STDOUT: %require_complete.441: <witness> = require_complete_type %V [symbolic]
  80. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  81. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  82. // CHECK:STDOUT: %Dest: type = symbolic_binding Dest, 0 [symbolic]
  83. // CHECK:STDOUT: %ImplicitAs.type.031: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
  84. // CHECK:STDOUT: %Self.738: %ImplicitAs.type.031 = symbolic_binding Self, 1 [symbolic]
  85. // CHECK:STDOUT: %ImplicitAs.assoc_type.ff3: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  86. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b3a: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs(%Dest, %Self.738) [symbolic]
  87. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.1de: %ImplicitAs.WithSelf.Convert.type.b3a = struct_value () [symbolic]
  88. // CHECK:STDOUT: %ImplicitAs.type.1e5: type = facet_type <@ImplicitAs, @ImplicitAs(%V)> [symbolic]
  89. // CHECK:STDOUT: %ImplicitAs.assoc_type.d88: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%V) [symbolic]
  90. // CHECK:STDOUT: %assoc0.3d8: %ImplicitAs.assoc_type.d88 = assoc_entity element0, imports.%Core.import_ref.201 [symbolic]
  91. // CHECK:STDOUT: %require_complete.cc6: <witness> = require_complete_type %ImplicitAs.type.1e5 [symbolic]
  92. // CHECK:STDOUT: %assoc0.843: %ImplicitAs.assoc_type.ff3 = assoc_entity element0, imports.%Core.import_ref.cc1 [symbolic]
  93. // CHECK:STDOUT: }
  94. // CHECK:STDOUT:
  95. // CHECK:STDOUT: imports {
  96. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  97. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  98. // CHECK:STDOUT: import Core//prelude
  99. // CHECK:STDOUT: import Core//prelude/...
  100. // CHECK:STDOUT: }
  101. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  102. // CHECK:STDOUT: %Core.import_ref.178: @ImplicitAs.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.ff3) = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, loaded [symbolic = @ImplicitAs.%assoc0 (constants.%assoc0.843)]
  103. // CHECK:STDOUT: %Core.import_ref.201: @ImplicitAs.%ImplicitAs.WithSelf.Convert.type (%ImplicitAs.WithSelf.Convert.type.b3a) = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, loaded [symbolic = @ImplicitAs.%ImplicitAs.WithSelf.Convert (constants.%ImplicitAs.WithSelf.Convert.1de)]
  104. // CHECK:STDOUT: %Core.import_ref.cc1 = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, unloaded
  105. // CHECK:STDOUT: }
  106. // CHECK:STDOUT:
  107. // CHECK:STDOUT: file {
  108. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  109. // CHECK:STDOUT: .Core = imports.%Core
  110. // CHECK:STDOUT: .C = %C.decl
  111. // CHECK:STDOUT: .F = %F.decl
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT: %Core.import = import Core
  114. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [concrete = constants.%C.generic] {
  115. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  116. // CHECK:STDOUT: } {
  117. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  118. // CHECK:STDOUT: %T.loc4_9.2: type = symbolic_binding T, 0 [symbolic = %T.loc4_9.1 (constants.%T)]
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  121. // CHECK:STDOUT: %U.patt: %pattern_type.98f = symbolic_binding_pattern U, 0 [concrete]
  122. // CHECK:STDOUT: %V.patt: %pattern_type.98f = symbolic_binding_pattern V, 1 [concrete]
  123. // CHECK:STDOUT: } {
  124. // CHECK:STDOUT: %.Self.1: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  125. // CHECK:STDOUT: %U.loc8_13.2: type = symbolic_binding U, 0 [symbolic = %U.loc8_13.1 (constants.%U)]
  126. // CHECK:STDOUT: %.Self.2: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  127. // CHECK:STDOUT: %V.loc8_23.2: type = symbolic_binding V, 1 [symbolic = %V.loc8_23.1 (constants.%V)]
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: generic class @C(%T.loc4_9.2: type) {
  132. // CHECK:STDOUT: %T.loc4_9.1: type = symbolic_binding T, 0 [symbolic = %T.loc4_9.1 (constants.%T)]
  133. // CHECK:STDOUT:
  134. // CHECK:STDOUT: !definition:
  135. // CHECK:STDOUT: %C.Create.type: type = fn_type @C.Create, @C(%T.loc4_9.1) [symbolic = %C.Create.type (constants.%C.Create.type.c11)]
  136. // CHECK:STDOUT: %C.Create: @C.%C.Create.type (%C.Create.type.c11) = struct_value () [symbolic = %C.Create (constants.%C.Create.723)]
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: class {
  139. // CHECK:STDOUT: %C.Create.decl: @C.%C.Create.type (%C.Create.type.c11) = fn_decl @C.Create [symbolic = @C.%C.Create (constants.%C.Create.723)] {
  140. // CHECK:STDOUT: %value.patt: @C.Create.%pattern_type (%pattern_type.51d1c4.1) = value_binding_pattern value [concrete]
  141. // CHECK:STDOUT: %value.param_patt: @C.Create.%pattern_type (%pattern_type.51d1c4.1) = value_param_pattern %value.patt, call_param0 [concrete]
  142. // CHECK:STDOUT: } {
  143. // CHECK:STDOUT: %value.param: @C.Create.%T (%T) = value_param call_param0
  144. // CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc4_9.2 [symbolic = %T (constants.%T)]
  145. // CHECK:STDOUT: %value: @C.Create.%T (%T) = value_binding value, %value.param
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  148. // CHECK:STDOUT: complete_type_witness = %complete_type
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: !members:
  151. // CHECK:STDOUT: .Self = constants.%C.5a3
  152. // CHECK:STDOUT: .T = <poisoned>
  153. // CHECK:STDOUT: .Create = %C.Create.decl
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT: }
  156. // CHECK:STDOUT:
  157. // CHECK:STDOUT: generic fn @C.Create(@C.%T.loc4_9.2: type) {
  158. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  159. // CHECK:STDOUT: %pattern_type: type = pattern_type %T [symbolic = %pattern_type (constants.%pattern_type.51d1c4.1)]
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: !definition:
  162. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic = %require_complete (constants.%require_complete.944)]
  163. // CHECK:STDOUT:
  164. // CHECK:STDOUT: fn(%value.param: @C.Create.%T (%T)) {
  165. // CHECK:STDOUT: !entry:
  166. // CHECK:STDOUT: return
  167. // CHECK:STDOUT: }
  168. // CHECK:STDOUT: }
  169. // CHECK:STDOUT:
  170. // CHECK:STDOUT: generic fn @F(%U.loc8_13.2: type, %V.loc8_23.2: type) {
  171. // CHECK:STDOUT: %U.loc8_13.1: type = symbolic_binding U, 0 [symbolic = %U.loc8_13.1 (constants.%U)]
  172. // CHECK:STDOUT: %V.loc8_23.1: type = symbolic_binding V, 1 [symbolic = %V.loc8_23.1 (constants.%V)]
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: !definition:
  175. // CHECK:STDOUT: %C.loc19_6.2: type = class_type @C, @C(%V.loc8_23.1) [symbolic = %C.loc19_6.2 (constants.%C.ee9)]
  176. // CHECK:STDOUT: %require_complete.loc19_7: <witness> = require_complete_type %C.loc19_6.2 [symbolic = %require_complete.loc19_7 (constants.%require_complete.1fc)]
  177. // CHECK:STDOUT: %C.Create.type: type = fn_type @C.Create, @C(%V.loc8_23.1) [symbolic = %C.Create.type (constants.%C.Create.type.c3d)]
  178. // CHECK:STDOUT: %C.Create: @F.%C.Create.type (%C.Create.type.c3d) = struct_value () [symbolic = %C.Create (constants.%C.Create.b40)]
  179. // CHECK:STDOUT: %C.Create.specific_fn.loc19_7.2: <specific function> = specific_function %C.Create, @C.Create(%V.loc8_23.1) [symbolic = %C.Create.specific_fn.loc19_7.2 (constants.%C.Create.specific_fn)]
  180. // CHECK:STDOUT: %require_complete.loc19_16.1: <witness> = require_complete_type %V.loc8_23.1 [symbolic = %require_complete.loc19_16.1 (constants.%require_complete.441)]
  181. // CHECK:STDOUT: %ImplicitAs.type.loc19_16.2: type = facet_type <@ImplicitAs, @ImplicitAs(%V.loc8_23.1)> [symbolic = %ImplicitAs.type.loc19_16.2 (constants.%ImplicitAs.type.1e5)]
  182. // CHECK:STDOUT: %require_complete.loc19_16.2: <witness> = require_complete_type %ImplicitAs.type.loc19_16.2 [symbolic = %require_complete.loc19_16.2 (constants.%require_complete.cc6)]
  183. // CHECK:STDOUT: %ImplicitAs.assoc_type: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%V.loc8_23.1) [symbolic = %ImplicitAs.assoc_type (constants.%ImplicitAs.assoc_type.d88)]
  184. // CHECK:STDOUT: %assoc0: @F.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.d88) = assoc_entity element0, imports.%Core.import_ref.201 [symbolic = %assoc0 (constants.%assoc0.3d8)]
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: fn() {
  187. // CHECK:STDOUT: !entry:
  188. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [concrete = constants.%C.generic]
  189. // CHECK:STDOUT: %V.ref: type = name_ref V, %V.loc8_23.2 [symbolic = %V.loc8_23.1 (constants.%V)]
  190. // CHECK:STDOUT: %C.loc19_6.1: type = class_type @C, @C(constants.%V) [symbolic = %C.loc19_6.2 (constants.%C.ee9)]
  191. // CHECK:STDOUT: %.loc19_7: @F.%C.Create.type (%C.Create.type.c3d) = specific_constant @C.%C.Create.decl, @C(constants.%V) [symbolic = %C.Create (constants.%C.Create.b40)]
  192. // CHECK:STDOUT: %Create.ref: @F.%C.Create.type (%C.Create.type.c3d) = name_ref Create, %.loc19_7 [symbolic = %C.Create (constants.%C.Create.b40)]
  193. // CHECK:STDOUT: %.loc19_16.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  194. // CHECK:STDOUT: %C.Create.specific_fn.loc19_7.1: <specific function> = specific_function %Create.ref, @C.Create(constants.%V) [symbolic = %C.Create.specific_fn.loc19_7.2 (constants.%C.Create.specific_fn)]
  195. // CHECK:STDOUT: %ImplicitAs.type.loc19_16.1: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%V)> [symbolic = %ImplicitAs.type.loc19_16.2 (constants.%ImplicitAs.type.1e5)]
  196. // CHECK:STDOUT: %.loc19_16.2: @F.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.d88) = specific_constant imports.%Core.import_ref.178, @ImplicitAs(constants.%V, constants.%Self.738) [symbolic = %assoc0 (constants.%assoc0.3d8)]
  197. // CHECK:STDOUT: %Convert.ref: @F.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.d88) = name_ref Convert, %.loc19_16.2 [symbolic = %assoc0 (constants.%assoc0.3d8)]
  198. // CHECK:STDOUT: %.loc19_16.3: @F.%V.loc8_23.1 (%V) = converted %.loc19_16.1, <error> [concrete = <error>]
  199. // CHECK:STDOUT: %C.Create.call: init %empty_tuple.type = call %C.Create.specific_fn.loc19_7.1(<error>)
  200. // CHECK:STDOUT: return
  201. // CHECK:STDOUT: }
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: specific @C(constants.%T) {
  205. // CHECK:STDOUT: %T.loc4_9.1 => constants.%T
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: !definition:
  208. // CHECK:STDOUT: %C.Create.type => constants.%C.Create.type.c11
  209. // CHECK:STDOUT: %C.Create => constants.%C.Create.723
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: specific @C.Create(constants.%T) {
  213. // CHECK:STDOUT: %T => constants.%T
  214. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d1c4.1
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT:
  217. // CHECK:STDOUT: specific @F(constants.%U, constants.%V) {
  218. // CHECK:STDOUT: %U.loc8_13.1 => constants.%U
  219. // CHECK:STDOUT: %V.loc8_23.1 => constants.%V
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: specific @C(constants.%V) {
  223. // CHECK:STDOUT: %T.loc4_9.1 => constants.%V
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: !definition:
  226. // CHECK:STDOUT: %C.Create.type => constants.%C.Create.type.c3d
  227. // CHECK:STDOUT: %C.Create => constants.%C.Create.b40
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: specific @C.Create(constants.%V) {
  231. // CHECK:STDOUT: %T => constants.%V
  232. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.946
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: !definition:
  235. // CHECK:STDOUT: %require_complete => constants.%require_complete.441
  236. // CHECK:STDOUT: }
  237. // CHECK:STDOUT:
  238. // CHECK:STDOUT: --- fail_todo_compatible_deduce.carbon
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: constants {
  241. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  242. // CHECK:STDOUT: %.Self.c39: %type = symbolic_binding .Self [symbolic_self]
  243. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic]
  244. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  245. // CHECK:STDOUT: %C.type: type = generic_class_type @C [concrete]
  246. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  247. // CHECK:STDOUT: %C.generic: %C.type = struct_value () [concrete]
  248. // CHECK:STDOUT: %C.5a3: type = class_type @C, @C(%T) [symbolic]
  249. // CHECK:STDOUT: %pattern_type.51d1c4.1: type = pattern_type %T [symbolic]
  250. // CHECK:STDOUT: %C.Create.type.c11: type = fn_type @C.Create, @C(%T) [symbolic]
  251. // CHECK:STDOUT: %C.Create.723: %C.Create.type.c11 = struct_value () [symbolic]
  252. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  253. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  254. // CHECK:STDOUT: %require_complete.944: <witness> = require_complete_type %T [symbolic]
  255. // CHECK:STDOUT: %U: type = symbolic_binding U, 0 [symbolic]
  256. // CHECK:STDOUT: %.Self.16f: type = symbolic_binding .Self [symbolic_self]
  257. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  258. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  259. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  260. // CHECK:STDOUT: %Dest: type = symbolic_binding Dest, 0 [symbolic]
  261. // CHECK:STDOUT: %ImplicitAs.type.031: type = facet_type <@ImplicitAs, @ImplicitAs(%Dest)> [symbolic]
  262. // CHECK:STDOUT: %Self.738: %ImplicitAs.type.031 = symbolic_binding Self, 1 [symbolic]
  263. // CHECK:STDOUT: %ImplicitAs.assoc_type.ff3: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%Dest) [symbolic]
  264. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b3a: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs(%Dest, %Self.738) [symbolic]
  265. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.1de: %ImplicitAs.WithSelf.Convert.type.b3a = struct_value () [symbolic]
  266. // CHECK:STDOUT: %ImplicitAs.type.f60: type = facet_type <@ImplicitAs, @ImplicitAs(%.Self.16f)> [symbolic_self]
  267. // CHECK:STDOUT: %type_where: type = facet_type <type where TODO> [concrete]
  268. // CHECK:STDOUT: %V: %type_where = symbolic_binding V, 1 [symbolic]
  269. // CHECK:STDOUT: %pattern_type.354: type = pattern_type %type_where [concrete]
  270. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  271. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  272. // CHECK:STDOUT: %V.binding.as_type: type = symbolic_binding_type V, 1, %V [symbolic]
  273. // CHECK:STDOUT: %C.bca: type = class_type @C, @C(%V.binding.as_type) [symbolic]
  274. // CHECK:STDOUT: %C.Create.type.242: type = fn_type @C.Create, @C(%V.binding.as_type) [symbolic]
  275. // CHECK:STDOUT: %C.Create.206: %C.Create.type.242 = struct_value () [symbolic]
  276. // CHECK:STDOUT: %require_complete.232: <witness> = require_complete_type %C.bca [symbolic]
  277. // CHECK:STDOUT: %pattern_type.20b: type = pattern_type %V.binding.as_type [symbolic]
  278. // CHECK:STDOUT: %C.Create.specific_fn: <specific function> = specific_function %C.Create.206, @C.Create(%V.binding.as_type) [symbolic]
  279. // CHECK:STDOUT: %require_complete.94b: <witness> = require_complete_type %V.binding.as_type [symbolic]
  280. // CHECK:STDOUT: %ImplicitAs.type.ee4: type = facet_type <@ImplicitAs, @ImplicitAs(%V.binding.as_type)> [symbolic]
  281. // CHECK:STDOUT: %ImplicitAs.assoc_type.f30: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%V.binding.as_type) [symbolic]
  282. // CHECK:STDOUT: %assoc0.a1c: %ImplicitAs.assoc_type.f30 = assoc_entity element0, imports.%Core.import_ref.201 [symbolic]
  283. // CHECK:STDOUT: %require_complete.24c: <witness> = require_complete_type %ImplicitAs.type.ee4 [symbolic]
  284. // CHECK:STDOUT: %assoc0.843: %ImplicitAs.assoc_type.ff3 = assoc_entity element0, imports.%Core.import_ref.cc1 [symbolic]
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: imports {
  288. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  289. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  290. // CHECK:STDOUT: import Core//prelude
  291. // CHECK:STDOUT: import Core//prelude/...
  292. // CHECK:STDOUT: }
  293. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  294. // CHECK:STDOUT: %Core.import_ref.178: @ImplicitAs.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.ff3) = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, loaded [symbolic = @ImplicitAs.%assoc0 (constants.%assoc0.843)]
  295. // CHECK:STDOUT: %Core.import_ref.201: @ImplicitAs.%ImplicitAs.WithSelf.Convert.type (%ImplicitAs.WithSelf.Convert.type.b3a) = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, loaded [symbolic = @ImplicitAs.%ImplicitAs.WithSelf.Convert (constants.%ImplicitAs.WithSelf.Convert.1de)]
  296. // CHECK:STDOUT: %Core.import_ref.cc1 = import_ref Core//prelude/parts/as, loc{{\d+_\d+}}, unloaded
  297. // CHECK:STDOUT: }
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: file {
  300. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  301. // CHECK:STDOUT: .Core = imports.%Core
  302. // CHECK:STDOUT: .C = %C.decl
  303. // CHECK:STDOUT: .F = %F.decl
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT: %Core.import = import Core
  306. // CHECK:STDOUT: %C.decl: %C.type = class_decl @C [concrete = constants.%C.generic] {
  307. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  308. // CHECK:STDOUT: } {
  309. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.c39]
  310. // CHECK:STDOUT: %T.loc4_9.2: type = symbolic_binding T, 0 [symbolic = %T.loc4_9.1 (constants.%T)]
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  313. // CHECK:STDOUT: %U.patt: %pattern_type.98f = symbolic_binding_pattern U, 0 [concrete]
  314. // CHECK:STDOUT: %V.patt: %pattern_type.354 = symbolic_binding_pattern V, 1 [concrete]
  315. // CHECK:STDOUT: } {
  316. // CHECK:STDOUT: %.Self.1: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.c39]
  317. // CHECK:STDOUT: %U.loc9_13.2: type = symbolic_binding U, 0 [symbolic = %U.loc9_13.1 (constants.%U)]
  318. // CHECK:STDOUT: %.loc9_32.1: type = splice_block %.loc9_32.2 [concrete = constants.%type_where] {
  319. // CHECK:STDOUT: %.Self.2: %type = symbolic_binding .Self [symbolic_self = constants.%.Self.c39]
  320. // CHECK:STDOUT: %.Self.3: type = symbolic_binding .Self [symbolic_self = constants.%.Self.16f]
  321. // CHECK:STDOUT: %.loc9_39.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  322. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  323. // CHECK:STDOUT: %ImplicitAs.ref: %ImplicitAs.type.cc7 = name_ref ImplicitAs, imports.%Core.ImplicitAs [concrete = constants.%ImplicitAs.generic]
  324. // CHECK:STDOUT: %.Self.ref: type = name_ref .Self, %.Self.3 [symbolic_self = constants.%.Self.16f]
  325. // CHECK:STDOUT: %ImplicitAs.type.loc9: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%.Self.16f)> [symbolic_self = constants.%ImplicitAs.type.f60]
  326. // CHECK:STDOUT: %.loc9_39.2: type = converted %.loc9_39.1, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  327. // CHECK:STDOUT: %.loc9_32.2: type = where_expr %.Self.3 [concrete = constants.%type_where] {
  328. // CHECK:STDOUT: requirement_base_facet_type type
  329. // CHECK:STDOUT: requirement_impls %.loc9_39.2, %ImplicitAs.type.loc9
  330. // CHECK:STDOUT: }
  331. // CHECK:STDOUT: }
  332. // CHECK:STDOUT: %V.loc9_23.2: %type_where = symbolic_binding V, 1 [symbolic = %V.loc9_23.1 (constants.%V)]
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: generic class @C(%T.loc4_9.2: type) {
  337. // CHECK:STDOUT: %T.loc4_9.1: type = symbolic_binding T, 0 [symbolic = %T.loc4_9.1 (constants.%T)]
  338. // CHECK:STDOUT:
  339. // CHECK:STDOUT: !definition:
  340. // CHECK:STDOUT: %C.Create.type: type = fn_type @C.Create, @C(%T.loc4_9.1) [symbolic = %C.Create.type (constants.%C.Create.type.c11)]
  341. // CHECK:STDOUT: %C.Create: @C.%C.Create.type (%C.Create.type.c11) = struct_value () [symbolic = %C.Create (constants.%C.Create.723)]
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: class {
  344. // CHECK:STDOUT: %C.Create.decl: @C.%C.Create.type (%C.Create.type.c11) = fn_decl @C.Create [symbolic = @C.%C.Create (constants.%C.Create.723)] {
  345. // CHECK:STDOUT: %value.patt: @C.Create.%pattern_type (%pattern_type.51d1c4.1) = value_binding_pattern value [concrete]
  346. // CHECK:STDOUT: %value.param_patt: @C.Create.%pattern_type (%pattern_type.51d1c4.1) = value_param_pattern %value.patt, call_param0 [concrete]
  347. // CHECK:STDOUT: } {
  348. // CHECK:STDOUT: %value.param: @C.Create.%T (%T) = value_param call_param0
  349. // CHECK:STDOUT: %T.ref: type = name_ref T, @C.%T.loc4_9.2 [symbolic = %T (constants.%T)]
  350. // CHECK:STDOUT: %value: @C.Create.%T (%T) = value_binding value, %value.param
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type]
  353. // CHECK:STDOUT: complete_type_witness = %complete_type
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: !members:
  356. // CHECK:STDOUT: .Self = constants.%C.5a3
  357. // CHECK:STDOUT: .T = <poisoned>
  358. // CHECK:STDOUT: .Create = %C.Create.decl
  359. // CHECK:STDOUT: }
  360. // CHECK:STDOUT: }
  361. // CHECK:STDOUT:
  362. // CHECK:STDOUT: generic fn @C.Create(@C.%T.loc4_9.2: type) {
  363. // CHECK:STDOUT: %T: type = symbolic_binding T, 0 [symbolic = %T (constants.%T)]
  364. // CHECK:STDOUT: %pattern_type: type = pattern_type %T [symbolic = %pattern_type (constants.%pattern_type.51d1c4.1)]
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: !definition:
  367. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %T [symbolic = %require_complete (constants.%require_complete.944)]
  368. // CHECK:STDOUT:
  369. // CHECK:STDOUT: fn(%value.param: @C.Create.%T (%T)) {
  370. // CHECK:STDOUT: !entry:
  371. // CHECK:STDOUT: return
  372. // CHECK:STDOUT: }
  373. // CHECK:STDOUT: }
  374. // CHECK:STDOUT:
  375. // CHECK:STDOUT: generic fn @F(%U.loc9_13.2: type, %V.loc9_23.2: %type_where) {
  376. // CHECK:STDOUT: %U.loc9_13.1: type = symbolic_binding U, 0 [symbolic = %U.loc9_13.1 (constants.%U)]
  377. // CHECK:STDOUT: %V.loc9_23.1: %type_where = symbolic_binding V, 1 [symbolic = %V.loc9_23.1 (constants.%V)]
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: !definition:
  380. // CHECK:STDOUT: %V.binding.as_type: type = symbolic_binding_type V, 1, %V.loc9_23.1 [symbolic = %V.binding.as_type (constants.%V.binding.as_type)]
  381. // CHECK:STDOUT: %C.loc20_6.2: type = class_type @C, @C(%V.binding.as_type) [symbolic = %C.loc20_6.2 (constants.%C.bca)]
  382. // CHECK:STDOUT: %require_complete.loc20_7: <witness> = require_complete_type %C.loc20_6.2 [symbolic = %require_complete.loc20_7 (constants.%require_complete.232)]
  383. // CHECK:STDOUT: %C.Create.type: type = fn_type @C.Create, @C(%V.binding.as_type) [symbolic = %C.Create.type (constants.%C.Create.type.242)]
  384. // CHECK:STDOUT: %C.Create: @F.%C.Create.type (%C.Create.type.242) = struct_value () [symbolic = %C.Create (constants.%C.Create.206)]
  385. // CHECK:STDOUT: %C.Create.specific_fn.loc20_7.2: <specific function> = specific_function %C.Create, @C.Create(%V.binding.as_type) [symbolic = %C.Create.specific_fn.loc20_7.2 (constants.%C.Create.specific_fn)]
  386. // CHECK:STDOUT: %require_complete.loc20_16.1: <witness> = require_complete_type %V.binding.as_type [symbolic = %require_complete.loc20_16.1 (constants.%require_complete.94b)]
  387. // CHECK:STDOUT: %ImplicitAs.type.loc20_16.2: type = facet_type <@ImplicitAs, @ImplicitAs(%V.binding.as_type)> [symbolic = %ImplicitAs.type.loc20_16.2 (constants.%ImplicitAs.type.ee4)]
  388. // CHECK:STDOUT: %require_complete.loc20_16.2: <witness> = require_complete_type %ImplicitAs.type.loc20_16.2 [symbolic = %require_complete.loc20_16.2 (constants.%require_complete.24c)]
  389. // CHECK:STDOUT: %ImplicitAs.assoc_type: type = assoc_entity_type @ImplicitAs, @ImplicitAs(%V.binding.as_type) [symbolic = %ImplicitAs.assoc_type (constants.%ImplicitAs.assoc_type.f30)]
  390. // CHECK:STDOUT: %assoc0: @F.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.f30) = assoc_entity element0, imports.%Core.import_ref.201 [symbolic = %assoc0 (constants.%assoc0.a1c)]
  391. // CHECK:STDOUT:
  392. // CHECK:STDOUT: fn() {
  393. // CHECK:STDOUT: !entry:
  394. // CHECK:STDOUT: %C.ref: %C.type = name_ref C, file.%C.decl [concrete = constants.%C.generic]
  395. // CHECK:STDOUT: %V.ref: %type_where = name_ref V, %V.loc9_23.2 [symbolic = %V.loc9_23.1 (constants.%V)]
  396. // CHECK:STDOUT: %V.as_type: type = facet_access_type %V.ref [symbolic = %V.binding.as_type (constants.%V.binding.as_type)]
  397. // CHECK:STDOUT: %.loc20_6: type = converted %V.ref, %V.as_type [symbolic = %V.binding.as_type (constants.%V.binding.as_type)]
  398. // CHECK:STDOUT: %C.loc20_6.1: type = class_type @C, @C(constants.%V.binding.as_type) [symbolic = %C.loc20_6.2 (constants.%C.bca)]
  399. // CHECK:STDOUT: %.loc20_7: @F.%C.Create.type (%C.Create.type.242) = specific_constant @C.%C.Create.decl, @C(constants.%V.binding.as_type) [symbolic = %C.Create (constants.%C.Create.206)]
  400. // CHECK:STDOUT: %Create.ref: @F.%C.Create.type (%C.Create.type.242) = name_ref Create, %.loc20_7 [symbolic = %C.Create (constants.%C.Create.206)]
  401. // CHECK:STDOUT: %.loc20_16.1: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  402. // CHECK:STDOUT: %C.Create.specific_fn.loc20_7.1: <specific function> = specific_function %Create.ref, @C.Create(constants.%V.binding.as_type) [symbolic = %C.Create.specific_fn.loc20_7.2 (constants.%C.Create.specific_fn)]
  403. // CHECK:STDOUT: %ImplicitAs.type.loc20_16.1: type = facet_type <@ImplicitAs, @ImplicitAs(constants.%V.binding.as_type)> [symbolic = %ImplicitAs.type.loc20_16.2 (constants.%ImplicitAs.type.ee4)]
  404. // CHECK:STDOUT: %.loc20_16.2: @F.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.f30) = specific_constant imports.%Core.import_ref.178, @ImplicitAs(constants.%V.binding.as_type, constants.%Self.738) [symbolic = %assoc0 (constants.%assoc0.a1c)]
  405. // CHECK:STDOUT: %Convert.ref: @F.%ImplicitAs.assoc_type (%ImplicitAs.assoc_type.f30) = name_ref Convert, %.loc20_16.2 [symbolic = %assoc0 (constants.%assoc0.a1c)]
  406. // CHECK:STDOUT: %.loc20_16.3: @F.%V.binding.as_type (%V.binding.as_type) = converted %.loc20_16.1, <error> [concrete = <error>]
  407. // CHECK:STDOUT: %C.Create.call: init %empty_tuple.type = call %C.Create.specific_fn.loc20_7.1(<error>)
  408. // CHECK:STDOUT: return
  409. // CHECK:STDOUT: }
  410. // CHECK:STDOUT: }
  411. // CHECK:STDOUT:
  412. // CHECK:STDOUT: specific @C(constants.%T) {
  413. // CHECK:STDOUT: %T.loc4_9.1 => constants.%T
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: !definition:
  416. // CHECK:STDOUT: %C.Create.type => constants.%C.Create.type.c11
  417. // CHECK:STDOUT: %C.Create => constants.%C.Create.723
  418. // CHECK:STDOUT: }
  419. // CHECK:STDOUT:
  420. // CHECK:STDOUT: specific @C.Create(constants.%T) {
  421. // CHECK:STDOUT: %T => constants.%T
  422. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.51d1c4.1
  423. // CHECK:STDOUT: }
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: specific @F(constants.%U, constants.%V) {
  426. // CHECK:STDOUT: %U.loc9_13.1 => constants.%U
  427. // CHECK:STDOUT: %V.loc9_23.1 => constants.%V
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT:
  430. // CHECK:STDOUT: specific @C(constants.%V.binding.as_type) {
  431. // CHECK:STDOUT: %T.loc4_9.1 => constants.%V.binding.as_type
  432. // CHECK:STDOUT:
  433. // CHECK:STDOUT: !definition:
  434. // CHECK:STDOUT: %C.Create.type => constants.%C.Create.type.242
  435. // CHECK:STDOUT: %C.Create => constants.%C.Create.206
  436. // CHECK:STDOUT: }
  437. // CHECK:STDOUT:
  438. // CHECK:STDOUT: specific @C.Create(constants.%V.binding.as_type) {
  439. // CHECK:STDOUT: %T => constants.%V.binding.as_type
  440. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.20b
  441. // CHECK:STDOUT:
  442. // CHECK:STDOUT: !definition:
  443. // CHECK:STDOUT: %require_complete => constants.%require_complete.94b
  444. // CHECK:STDOUT: }
  445. // CHECK:STDOUT: