generic.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  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. // TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
  6. // EXTRA-ARGS: --dump-sem-ir-ranges=if-present
  7. //
  8. // AUTOUPDATE
  9. // TIP: To test this file alone, run:
  10. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/interface/no_prelude/generic.carbon
  11. // TIP: To dump output, run:
  12. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/no_prelude/generic.carbon
  13. // --- generic.carbon
  14. library "[[@TEST_NAME]]";
  15. interface Simple(T:! type) {}
  16. class X {}
  17. interface WithAssocFn(T:! type) {
  18. // TODO: Take `Self`, return `T`, once that works.
  19. fn F() -> X;
  20. }
  21. class C {
  22. impl as Simple(C) {}
  23. impl as WithAssocFn(C) {
  24. fn F() -> X {
  25. return {};
  26. }
  27. }
  28. }
  29. interface WithImplicitArgs[T:! type](N:! T);
  30. fn Receive(T:! Simple(C)) {}
  31. fn Pass(T:! Simple(C)) {
  32. Receive(T);
  33. }
  34. // --- fail_mismatched_args.carbon
  35. library "[[@TEST_NAME]]";
  36. interface Generic(T:! type) {}
  37. class A {}
  38. class B {}
  39. fn F(T:! Generic(A));
  40. fn G(T:! Generic(B)) {
  41. // CHECK:STDERR: fail_mismatched_args.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `Generic(B)` into type implementing `Generic(A)` [ConversionFailureFacetToFacet]
  42. // CHECK:STDERR: F(T);
  43. // CHECK:STDERR: ^~~~
  44. // CHECK:STDERR: fail_mismatched_args.carbon:[[@LINE-5]]:6: note: initializing generic parameter `T` declared here [InitializingGenericParam]
  45. // CHECK:STDERR: fn F(T:! Generic(A));
  46. // CHECK:STDERR: ^
  47. // CHECK:STDERR:
  48. F(T);
  49. }
  50. // CHECK:STDOUT: --- generic.carbon
  51. // CHECK:STDOUT:
  52. // CHECK:STDOUT: constants {
  53. // CHECK:STDOUT: %T.8b3: type = bind_symbolic_name T, 0 [symbolic]
  54. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  55. // CHECK:STDOUT: %Simple.type.3b3: type = generic_interface_type @Simple [concrete]
  56. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  57. // CHECK:STDOUT: %Simple.generic: %Simple.type.3b3 = struct_value () [concrete]
  58. // CHECK:STDOUT: %Simple.type.d08: type = facet_type <@Simple, @Simple(%T.8b3)> [symbolic]
  59. // CHECK:STDOUT: %Self.faf: %Simple.type.d08 = bind_symbolic_name Self, 1 [symbolic]
  60. // CHECK:STDOUT: %X: type = class_type @X [concrete]
  61. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  62. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  63. // CHECK:STDOUT: %WithAssocFn.type.509: type = generic_interface_type @WithAssocFn [concrete]
  64. // CHECK:STDOUT: %WithAssocFn.generic: %WithAssocFn.type.509 = struct_value () [concrete]
  65. // CHECK:STDOUT: %WithAssocFn.type.ce6: type = facet_type <@WithAssocFn, @WithAssocFn(%T.8b3)> [symbolic]
  66. // CHECK:STDOUT: %Self.088: %WithAssocFn.type.ce6 = bind_symbolic_name Self, 1 [symbolic]
  67. // CHECK:STDOUT: %pattern_type.019: type = pattern_type %X [concrete]
  68. // CHECK:STDOUT: %F.type.1af: type = fn_type @F.1, @WithAssocFn(%T.8b3) [symbolic]
  69. // CHECK:STDOUT: %F.b7d: %F.type.1af = struct_value () [symbolic]
  70. // CHECK:STDOUT: %WithAssocFn.assoc_type.b2f: type = assoc_entity_type @WithAssocFn, @WithAssocFn(%T.8b3) [symbolic]
  71. // CHECK:STDOUT: %assoc0.fc5: %WithAssocFn.assoc_type.b2f = assoc_entity element0, @WithAssocFn.%F.decl [symbolic]
  72. // CHECK:STDOUT: %C: type = class_type @C [concrete]
  73. // CHECK:STDOUT: %Simple.type.51f: type = facet_type <@Simple, @Simple(%C)> [concrete]
  74. // CHECK:STDOUT: %Self.21f: %Simple.type.51f = bind_symbolic_name Self, 1 [symbolic]
  75. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness @C.%Simple.impl_witness_table [concrete]
  76. // CHECK:STDOUT: %WithAssocFn.type.683: type = facet_type <@WithAssocFn, @WithAssocFn(%C)> [concrete]
  77. // CHECK:STDOUT: %Self.7ae: %WithAssocFn.type.683 = bind_symbolic_name Self, 1 [symbolic]
  78. // CHECK:STDOUT: %F.type.18c: type = fn_type @F.1, @WithAssocFn(%C) [concrete]
  79. // CHECK:STDOUT: %F.e46: %F.type.18c = struct_value () [concrete]
  80. // CHECK:STDOUT: %WithAssocFn.assoc_type.9ea: type = assoc_entity_type @WithAssocFn, @WithAssocFn(%C) [concrete]
  81. // CHECK:STDOUT: %assoc0.cad: %WithAssocFn.assoc_type.9ea = assoc_entity element0, @WithAssocFn.%F.decl [concrete]
  82. // CHECK:STDOUT: %WithAssocFn.impl_witness: <witness> = impl_witness @C.%WithAssocFn.impl_witness_table [concrete]
  83. // CHECK:STDOUT: %F.type.005: type = fn_type @F.2 [concrete]
  84. // CHECK:STDOUT: %F.317: %F.type.005 = struct_value () [concrete]
  85. // CHECK:STDOUT: %WithAssocFn.facet: %WithAssocFn.type.683 = facet_value %C, (%WithAssocFn.impl_witness) [concrete]
  86. // CHECK:STDOUT: %X.val: %X = struct_value () [concrete]
  87. // CHECK:STDOUT: %N: %T.8b3 = bind_symbolic_name N, 1 [symbolic]
  88. // CHECK:STDOUT: %pattern_type.7dc: type = pattern_type %T.8b3 [symbolic]
  89. // CHECK:STDOUT: %WithImplicitArgs.type: type = generic_interface_type @WithImplicitArgs [concrete]
  90. // CHECK:STDOUT: %WithImplicitArgs.generic: %WithImplicitArgs.type = struct_value () [concrete]
  91. // CHECK:STDOUT: %T.692: %Simple.type.51f = bind_symbolic_name T, 0 [symbolic]
  92. // CHECK:STDOUT: %pattern_type.353: type = pattern_type %Simple.type.51f [concrete]
  93. // CHECK:STDOUT: %Receive.type: type = fn_type @Receive [concrete]
  94. // CHECK:STDOUT: %Receive: %Receive.type = struct_value () [concrete]
  95. // CHECK:STDOUT: %Pass.type: type = fn_type @Pass [concrete]
  96. // CHECK:STDOUT: %Pass: %Pass.type = struct_value () [concrete]
  97. // CHECK:STDOUT: %Receive.specific_fn: <specific function> = specific_function %Receive, @Receive(%T.692) [symbolic]
  98. // CHECK:STDOUT: }
  99. // CHECK:STDOUT:
  100. // CHECK:STDOUT: file {
  101. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  102. // CHECK:STDOUT: .Simple = %Simple.decl
  103. // CHECK:STDOUT: .X = %X.decl
  104. // CHECK:STDOUT: .WithAssocFn = %WithAssocFn.decl
  105. // CHECK:STDOUT: .C = %C.decl
  106. // CHECK:STDOUT: .WithImplicitArgs = %WithImplicitArgs.decl
  107. // CHECK:STDOUT: .Receive = %Receive.decl
  108. // CHECK:STDOUT: .Pass = %Pass.decl
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: %Simple.decl: %Simple.type.3b3 = interface_decl @Simple [concrete = constants.%Simple.generic] {
  111. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  112. // CHECK:STDOUT: } {
  113. // CHECK:STDOUT: %T.loc4_18.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_18.2 (constants.%T.8b3)]
  114. // CHECK:STDOUT: }
  115. // CHECK:STDOUT: %X.decl: type = class_decl @X [concrete = constants.%X] {} {}
  116. // CHECK:STDOUT: %WithAssocFn.decl: %WithAssocFn.type.509 = interface_decl @WithAssocFn [concrete = constants.%WithAssocFn.generic] {
  117. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  118. // CHECK:STDOUT: } {
  119. // CHECK:STDOUT: %T.loc8_23.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_23.2 (constants.%T.8b3)]
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT: %C.decl: type = class_decl @C [concrete = constants.%C] {} {}
  122. // CHECK:STDOUT: %WithImplicitArgs.decl: %WithImplicitArgs.type = interface_decl @WithImplicitArgs [concrete = constants.%WithImplicitArgs.generic] {
  123. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  124. // CHECK:STDOUT: %N.patt: @WithImplicitArgs.%pattern_type (%pattern_type.7dc) = symbolic_binding_pattern N, 1 [concrete]
  125. // CHECK:STDOUT: } {
  126. // CHECK:STDOUT: %T.loc22_28.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc22_28.2 (constants.%T.8b3)]
  127. // CHECK:STDOUT: %T.ref: type = name_ref T, %T.loc22_28.1 [symbolic = %T.loc22_28.2 (constants.%T.8b3)]
  128. // CHECK:STDOUT: %N.loc22_38.1: @WithImplicitArgs.%T.loc22_28.2 (%T.8b3) = bind_symbolic_name N, 1 [symbolic = %N.loc22_38.2 (constants.%N)]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT: %Receive.decl: %Receive.type = fn_decl @Receive [concrete = constants.%Receive] {
  131. // CHECK:STDOUT: %T.patt: %pattern_type.353 = symbolic_binding_pattern T, 0 [concrete]
  132. // CHECK:STDOUT: } {
  133. // CHECK:STDOUT: %.loc24: type = splice_block %Simple.type [concrete = constants.%Simple.type.51f] {
  134. // CHECK:STDOUT: %Simple.ref: %Simple.type.3b3 = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.generic]
  135. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  136. // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple, @Simple(constants.%C)> [concrete = constants.%Simple.type.51f]
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: %T.loc24_12.1: %Simple.type.51f = bind_symbolic_name T, 0 [symbolic = %T.loc24_12.2 (constants.%T.692)]
  139. // CHECK:STDOUT: }
  140. // CHECK:STDOUT: %Pass.decl: %Pass.type = fn_decl @Pass [concrete = constants.%Pass] {
  141. // CHECK:STDOUT: %T.patt: %pattern_type.353 = symbolic_binding_pattern T, 0 [concrete]
  142. // CHECK:STDOUT: } {
  143. // CHECK:STDOUT: %.loc25: type = splice_block %Simple.type [concrete = constants.%Simple.type.51f] {
  144. // CHECK:STDOUT: %Simple.ref: %Simple.type.3b3 = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.generic]
  145. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  146. // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple, @Simple(constants.%C)> [concrete = constants.%Simple.type.51f]
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: %T.loc25_9.1: %Simple.type.51f = bind_symbolic_name T, 0 [symbolic = %T.loc25_9.2 (constants.%T.692)]
  149. // CHECK:STDOUT: }
  150. // CHECK:STDOUT: }
  151. // CHECK:STDOUT:
  152. // CHECK:STDOUT: generic interface @Simple(%T.loc4_18.1: type) {
  153. // CHECK:STDOUT: %T.loc4_18.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_18.2 (constants.%T.8b3)]
  154. // CHECK:STDOUT:
  155. // CHECK:STDOUT: !definition:
  156. // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple, @Simple(%T.loc4_18.2)> [symbolic = %Simple.type (constants.%Simple.type.d08)]
  157. // CHECK:STDOUT: %Self.2: @Simple.%Simple.type (%Simple.type.d08) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.faf)]
  158. // CHECK:STDOUT:
  159. // CHECK:STDOUT: interface {
  160. // CHECK:STDOUT: %Self.1: @Simple.%Simple.type (%Simple.type.d08) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.faf)]
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: !members:
  163. // CHECK:STDOUT: .Self = %Self.1
  164. // CHECK:STDOUT: witness = ()
  165. // CHECK:STDOUT: }
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: generic interface @WithAssocFn(%T.loc8_23.1: type) {
  169. // CHECK:STDOUT: %T.loc8_23.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc8_23.2 (constants.%T.8b3)]
  170. // CHECK:STDOUT:
  171. // CHECK:STDOUT: !definition:
  172. // CHECK:STDOUT: %WithAssocFn.type: type = facet_type <@WithAssocFn, @WithAssocFn(%T.loc8_23.2)> [symbolic = %WithAssocFn.type (constants.%WithAssocFn.type.ce6)]
  173. // CHECK:STDOUT: %Self.2: @WithAssocFn.%WithAssocFn.type (%WithAssocFn.type.ce6) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.088)]
  174. // CHECK:STDOUT: %F.type: type = fn_type @F.1, @WithAssocFn(%T.loc8_23.2) [symbolic = %F.type (constants.%F.type.1af)]
  175. // CHECK:STDOUT: %F: @WithAssocFn.%F.type (%F.type.1af) = struct_value () [symbolic = %F (constants.%F.b7d)]
  176. // CHECK:STDOUT: %WithAssocFn.assoc_type: type = assoc_entity_type @WithAssocFn, @WithAssocFn(%T.loc8_23.2) [symbolic = %WithAssocFn.assoc_type (constants.%WithAssocFn.assoc_type.b2f)]
  177. // CHECK:STDOUT: %assoc0.loc10_14.2: @WithAssocFn.%WithAssocFn.assoc_type (%WithAssocFn.assoc_type.b2f) = assoc_entity element0, %F.decl [symbolic = %assoc0.loc10_14.2 (constants.%assoc0.fc5)]
  178. // CHECK:STDOUT:
  179. // CHECK:STDOUT: interface {
  180. // CHECK:STDOUT: %Self.1: @WithAssocFn.%WithAssocFn.type (%WithAssocFn.type.ce6) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self.088)]
  181. // CHECK:STDOUT: %F.decl: @WithAssocFn.%F.type (%F.type.1af) = fn_decl @F.1 [symbolic = @WithAssocFn.%F (constants.%F.b7d)] {
  182. // CHECK:STDOUT: %return.patt: %pattern_type.019 = return_slot_pattern [concrete]
  183. // CHECK:STDOUT: %return.param_patt: %pattern_type.019 = out_param_pattern %return.patt, call_param0 [concrete]
  184. // CHECK:STDOUT: } {
  185. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [concrete = constants.%X]
  186. // CHECK:STDOUT: %return.param: ref %X = out_param call_param0
  187. // CHECK:STDOUT: %return: ref %X = return_slot %return.param
  188. // CHECK:STDOUT: }
  189. // CHECK:STDOUT: %assoc0.loc10_14.1: @WithAssocFn.%WithAssocFn.assoc_type (%WithAssocFn.assoc_type.b2f) = assoc_entity element0, %F.decl [symbolic = %assoc0.loc10_14.2 (constants.%assoc0.fc5)]
  190. // CHECK:STDOUT:
  191. // CHECK:STDOUT: !members:
  192. // CHECK:STDOUT: .Self = %Self.1
  193. // CHECK:STDOUT: .X = <poisoned>
  194. // CHECK:STDOUT: .F = %assoc0.loc10_14.1
  195. // CHECK:STDOUT: witness = (%F.decl)
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT: }
  198. // CHECK:STDOUT:
  199. // CHECK:STDOUT: generic interface @WithImplicitArgs(%T.loc22_28.1: type, %N.loc22_38.1: @WithImplicitArgs.%T.loc22_28.2 (%T.8b3)) {
  200. // CHECK:STDOUT: %T.loc22_28.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc22_28.2 (constants.%T.8b3)]
  201. // CHECK:STDOUT: %N.loc22_38.2: @WithImplicitArgs.%T.loc22_28.2 (%T.8b3) = bind_symbolic_name N, 1 [symbolic = %N.loc22_38.2 (constants.%N)]
  202. // CHECK:STDOUT: %pattern_type: type = pattern_type %T.loc22_28.2 [symbolic = %pattern_type (constants.%pattern_type.7dc)]
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: interface;
  205. // CHECK:STDOUT: }
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: impl @impl.763: %Self.ref as %Simple.type {
  208. // CHECK:STDOUT: !members:
  209. // CHECK:STDOUT: witness = @C.%Simple.impl_witness
  210. // CHECK:STDOUT: }
  211. // CHECK:STDOUT:
  212. // CHECK:STDOUT: impl @impl.90b: %Self.ref as %WithAssocFn.type {
  213. // CHECK:STDOUT: %F.decl: %F.type.005 = fn_decl @F.2 [concrete = constants.%F.317] {
  214. // CHECK:STDOUT: %return.patt: %pattern_type.019 = return_slot_pattern [concrete]
  215. // CHECK:STDOUT: %return.param_patt: %pattern_type.019 = out_param_pattern %return.patt, call_param0 [concrete]
  216. // CHECK:STDOUT: } {
  217. // CHECK:STDOUT: %X.ref: type = name_ref X, file.%X.decl [concrete = constants.%X]
  218. // CHECK:STDOUT: %return.param: ref %X = out_param call_param0
  219. // CHECK:STDOUT: %return: ref %X = return_slot %return.param
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: !members:
  223. // CHECK:STDOUT: .X = <poisoned>
  224. // CHECK:STDOUT: .F = %F.decl
  225. // CHECK:STDOUT: witness = @C.%WithAssocFn.impl_witness
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: class @X {
  229. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  230. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  231. // CHECK:STDOUT: complete_type_witness = %complete_type
  232. // CHECK:STDOUT:
  233. // CHECK:STDOUT: !members:
  234. // CHECK:STDOUT: .Self = constants.%X
  235. // CHECK:STDOUT: }
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: class @C {
  238. // CHECK:STDOUT: impl_decl @impl.763 [concrete] {} {
  239. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  240. // CHECK:STDOUT: %Simple.ref: %Simple.type.3b3 = name_ref Simple, file.%Simple.decl [concrete = constants.%Simple.generic]
  241. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  242. // CHECK:STDOUT: %Simple.type: type = facet_type <@Simple, @Simple(constants.%C)> [concrete = constants.%Simple.type.51f]
  243. // CHECK:STDOUT: }
  244. // CHECK:STDOUT: %Simple.impl_witness_table = impl_witness_table (), @impl.763 [concrete]
  245. // CHECK:STDOUT: %Simple.impl_witness: <witness> = impl_witness %Simple.impl_witness_table [concrete = constants.%Simple.impl_witness]
  246. // CHECK:STDOUT: impl_decl @impl.90b [concrete] {} {
  247. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%C [concrete = constants.%C]
  248. // CHECK:STDOUT: %WithAssocFn.ref: %WithAssocFn.type.509 = name_ref WithAssocFn, file.%WithAssocFn.decl [concrete = constants.%WithAssocFn.generic]
  249. // CHECK:STDOUT: %C.ref: type = name_ref C, file.%C.decl [concrete = constants.%C]
  250. // CHECK:STDOUT: %WithAssocFn.type: type = facet_type <@WithAssocFn, @WithAssocFn(constants.%C)> [concrete = constants.%WithAssocFn.type.683]
  251. // CHECK:STDOUT: }
  252. // CHECK:STDOUT: %WithAssocFn.impl_witness_table = impl_witness_table (@impl.90b.%F.decl), @impl.90b [concrete]
  253. // CHECK:STDOUT: %WithAssocFn.impl_witness: <witness> = impl_witness %WithAssocFn.impl_witness_table [concrete = constants.%WithAssocFn.impl_witness]
  254. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  255. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  256. // CHECK:STDOUT: complete_type_witness = %complete_type
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: !members:
  259. // CHECK:STDOUT: .Self = constants.%C
  260. // CHECK:STDOUT: .Simple = <poisoned>
  261. // CHECK:STDOUT: .C = <poisoned>
  262. // CHECK:STDOUT: .WithAssocFn = <poisoned>
  263. // CHECK:STDOUT: .X = <poisoned>
  264. // CHECK:STDOUT: }
  265. // CHECK:STDOUT:
  266. // CHECK:STDOUT: generic fn @F.1(@WithAssocFn.%T.loc8_23.1: type, @WithAssocFn.%Self.1: @WithAssocFn.%WithAssocFn.type (%WithAssocFn.type.ce6)) {
  267. // CHECK:STDOUT: fn() -> %return.param: %X;
  268. // CHECK:STDOUT: }
  269. // CHECK:STDOUT:
  270. // CHECK:STDOUT: fn @F.2() -> %return.param: %X {
  271. // CHECK:STDOUT: !entry:
  272. // CHECK:STDOUT: %.loc17_15.1: %empty_struct_type = struct_literal ()
  273. // CHECK:STDOUT: %.loc17_15.2: init %X = class_init (), %return [concrete = constants.%X.val]
  274. // CHECK:STDOUT: %.loc17_16: init %X = converted %.loc17_15.1, %.loc17_15.2 [concrete = constants.%X.val]
  275. // CHECK:STDOUT: return %.loc17_16 to %return
  276. // CHECK:STDOUT: }
  277. // CHECK:STDOUT:
  278. // CHECK:STDOUT: generic fn @Receive(%T.loc24_12.1: %Simple.type.51f) {
  279. // CHECK:STDOUT: %T.loc24_12.2: %Simple.type.51f = bind_symbolic_name T, 0 [symbolic = %T.loc24_12.2 (constants.%T.692)]
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: !definition:
  282. // CHECK:STDOUT:
  283. // CHECK:STDOUT: fn() {
  284. // CHECK:STDOUT: !entry:
  285. // CHECK:STDOUT: return
  286. // CHECK:STDOUT: }
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: generic fn @Pass(%T.loc25_9.1: %Simple.type.51f) {
  290. // CHECK:STDOUT: %T.loc25_9.2: %Simple.type.51f = bind_symbolic_name T, 0 [symbolic = %T.loc25_9.2 (constants.%T.692)]
  291. // CHECK:STDOUT:
  292. // CHECK:STDOUT: !definition:
  293. // CHECK:STDOUT: %Receive.specific_fn.loc26_3.2: <specific function> = specific_function constants.%Receive, @Receive(%T.loc25_9.2) [symbolic = %Receive.specific_fn.loc26_3.2 (constants.%Receive.specific_fn)]
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: fn() {
  296. // CHECK:STDOUT: !entry:
  297. // CHECK:STDOUT: %Receive.ref: %Receive.type = name_ref Receive, file.%Receive.decl [concrete = constants.%Receive]
  298. // CHECK:STDOUT: %T.ref: %Simple.type.51f = name_ref T, %T.loc25_9.1 [symbolic = %T.loc25_9.2 (constants.%T.692)]
  299. // CHECK:STDOUT: %Receive.specific_fn.loc26_3.1: <specific function> = specific_function %Receive.ref, @Receive(constants.%T.692) [symbolic = %Receive.specific_fn.loc26_3.2 (constants.%Receive.specific_fn)]
  300. // CHECK:STDOUT: %Receive.call: init %empty_tuple.type = call %Receive.specific_fn.loc26_3.1()
  301. // CHECK:STDOUT: return
  302. // CHECK:STDOUT: }
  303. // CHECK:STDOUT: }
  304. // CHECK:STDOUT:
  305. // CHECK:STDOUT: specific @Simple(constants.%T.8b3) {
  306. // CHECK:STDOUT: %T.loc4_18.2 => constants.%T.8b3
  307. // CHECK:STDOUT: }
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: specific @WithAssocFn(constants.%T.8b3) {
  310. // CHECK:STDOUT: %T.loc8_23.2 => constants.%T.8b3
  311. // CHECK:STDOUT: }
  312. // CHECK:STDOUT:
  313. // CHECK:STDOUT: specific @F.1(constants.%T.8b3, constants.%Self.088) {}
  314. // CHECK:STDOUT:
  315. // CHECK:STDOUT: specific @Simple(constants.%C) {
  316. // CHECK:STDOUT: %T.loc4_18.2 => constants.%C
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: !definition:
  319. // CHECK:STDOUT: %Simple.type => constants.%Simple.type.51f
  320. // CHECK:STDOUT: %Self.2 => constants.%Self.21f
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: specific @WithAssocFn(constants.%C) {
  324. // CHECK:STDOUT: %T.loc8_23.2 => constants.%C
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: !definition:
  327. // CHECK:STDOUT: %WithAssocFn.type => constants.%WithAssocFn.type.683
  328. // CHECK:STDOUT: %Self.2 => constants.%Self.7ae
  329. // CHECK:STDOUT: %F.type => constants.%F.type.18c
  330. // CHECK:STDOUT: %F => constants.%F.e46
  331. // CHECK:STDOUT: %WithAssocFn.assoc_type => constants.%WithAssocFn.assoc_type.9ea
  332. // CHECK:STDOUT: %assoc0.loc10_14.2 => constants.%assoc0.cad
  333. // CHECK:STDOUT: }
  334. // CHECK:STDOUT:
  335. // CHECK:STDOUT: specific @F.1(constants.%C, constants.%WithAssocFn.facet) {}
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: specific @WithImplicitArgs(constants.%T.8b3, constants.%N) {
  338. // CHECK:STDOUT: %T.loc22_28.2 => constants.%T.8b3
  339. // CHECK:STDOUT: %N.loc22_38.2 => constants.%N
  340. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7dc
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: specific @Receive(constants.%T.692) {
  344. // CHECK:STDOUT: %T.loc24_12.2 => constants.%T.692
  345. // CHECK:STDOUT:
  346. // CHECK:STDOUT: !definition:
  347. // CHECK:STDOUT: }
  348. // CHECK:STDOUT:
  349. // CHECK:STDOUT: specific @Pass(constants.%T.692) {
  350. // CHECK:STDOUT: %T.loc25_9.2 => constants.%T.692
  351. // CHECK:STDOUT: }
  352. // CHECK:STDOUT:
  353. // CHECK:STDOUT: --- fail_mismatched_args.carbon
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: constants {
  356. // CHECK:STDOUT: %T.8b3: type = bind_symbolic_name T, 0 [symbolic]
  357. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  358. // CHECK:STDOUT: %Generic.type.c21: type = generic_interface_type @Generic [concrete]
  359. // CHECK:STDOUT: %Generic.generic: %Generic.type.c21 = struct_value () [concrete]
  360. // CHECK:STDOUT: %Generic.type.91c: type = facet_type <@Generic, @Generic(%T.8b3)> [symbolic]
  361. // CHECK:STDOUT: %Self: %Generic.type.91c = bind_symbolic_name Self, 1 [symbolic]
  362. // CHECK:STDOUT: %A: type = class_type @A [concrete]
  363. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  364. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete]
  365. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  366. // CHECK:STDOUT: %Generic.type.c7c: type = facet_type <@Generic, @Generic(%A)> [concrete]
  367. // CHECK:STDOUT: %T.a53: %Generic.type.c7c = bind_symbolic_name T, 0 [symbolic]
  368. // CHECK:STDOUT: %pattern_type.6ea: type = pattern_type %Generic.type.c7c [concrete]
  369. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  370. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  371. // CHECK:STDOUT: %Generic.type.4ce: type = facet_type <@Generic, @Generic(%B)> [concrete]
  372. // CHECK:STDOUT: %T.bae: %Generic.type.4ce = bind_symbolic_name T, 0 [symbolic]
  373. // CHECK:STDOUT: %pattern_type.f4a: type = pattern_type %Generic.type.4ce [concrete]
  374. // CHECK:STDOUT: %G.type: type = fn_type @G [concrete]
  375. // CHECK:STDOUT: %G: %G.type = struct_value () [concrete]
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: file {
  379. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  380. // CHECK:STDOUT: .Generic = %Generic.decl
  381. // CHECK:STDOUT: .A = %A.decl
  382. // CHECK:STDOUT: .B = %B.decl
  383. // CHECK:STDOUT: .F = %F.decl
  384. // CHECK:STDOUT: .G = %G.decl
  385. // CHECK:STDOUT: }
  386. // CHECK:STDOUT: %Generic.decl: %Generic.type.c21 = interface_decl @Generic [concrete = constants.%Generic.generic] {
  387. // CHECK:STDOUT: %T.patt: %pattern_type.98f = symbolic_binding_pattern T, 0 [concrete]
  388. // CHECK:STDOUT: } {
  389. // CHECK:STDOUT: %T.loc4_19.1: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_19.2 (constants.%T.8b3)]
  390. // CHECK:STDOUT: }
  391. // CHECK:STDOUT: %A.decl: type = class_decl @A [concrete = constants.%A] {} {}
  392. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  393. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  394. // CHECK:STDOUT: %T.patt: %pattern_type.6ea = symbolic_binding_pattern T, 0 [concrete]
  395. // CHECK:STDOUT: } {
  396. // CHECK:STDOUT: %.loc9: type = splice_block %Generic.type [concrete = constants.%Generic.type.c7c] {
  397. // CHECK:STDOUT: %Generic.ref: %Generic.type.c21 = name_ref Generic, file.%Generic.decl [concrete = constants.%Generic.generic]
  398. // CHECK:STDOUT: %A.ref: type = name_ref A, file.%A.decl [concrete = constants.%A]
  399. // CHECK:STDOUT: %Generic.type: type = facet_type <@Generic, @Generic(constants.%A)> [concrete = constants.%Generic.type.c7c]
  400. // CHECK:STDOUT: }
  401. // CHECK:STDOUT: %T.loc9_6.1: %Generic.type.c7c = bind_symbolic_name T, 0 [symbolic = %T.loc9_6.2 (constants.%T.a53)]
  402. // CHECK:STDOUT: }
  403. // CHECK:STDOUT: %G.decl: %G.type = fn_decl @G [concrete = constants.%G] {
  404. // CHECK:STDOUT: %T.patt: %pattern_type.f4a = symbolic_binding_pattern T, 0 [concrete]
  405. // CHECK:STDOUT: } {
  406. // CHECK:STDOUT: %.loc10: type = splice_block %Generic.type [concrete = constants.%Generic.type.4ce] {
  407. // CHECK:STDOUT: %Generic.ref: %Generic.type.c21 = name_ref Generic, file.%Generic.decl [concrete = constants.%Generic.generic]
  408. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  409. // CHECK:STDOUT: %Generic.type: type = facet_type <@Generic, @Generic(constants.%B)> [concrete = constants.%Generic.type.4ce]
  410. // CHECK:STDOUT: }
  411. // CHECK:STDOUT: %T.loc10_6.1: %Generic.type.4ce = bind_symbolic_name T, 0 [symbolic = %T.loc10_6.2 (constants.%T.bae)]
  412. // CHECK:STDOUT: }
  413. // CHECK:STDOUT: }
  414. // CHECK:STDOUT:
  415. // CHECK:STDOUT: generic interface @Generic(%T.loc4_19.1: type) {
  416. // CHECK:STDOUT: %T.loc4_19.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc4_19.2 (constants.%T.8b3)]
  417. // CHECK:STDOUT:
  418. // CHECK:STDOUT: !definition:
  419. // CHECK:STDOUT: %Generic.type: type = facet_type <@Generic, @Generic(%T.loc4_19.2)> [symbolic = %Generic.type (constants.%Generic.type.91c)]
  420. // CHECK:STDOUT: %Self.2: @Generic.%Generic.type (%Generic.type.91c) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  421. // CHECK:STDOUT:
  422. // CHECK:STDOUT: interface {
  423. // CHECK:STDOUT: %Self.1: @Generic.%Generic.type (%Generic.type.91c) = bind_symbolic_name Self, 1 [symbolic = %Self.2 (constants.%Self)]
  424. // CHECK:STDOUT:
  425. // CHECK:STDOUT: !members:
  426. // CHECK:STDOUT: .Self = %Self.1
  427. // CHECK:STDOUT: witness = ()
  428. // CHECK:STDOUT: }
  429. // CHECK:STDOUT: }
  430. // CHECK:STDOUT:
  431. // CHECK:STDOUT: class @A {
  432. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  433. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  434. // CHECK:STDOUT: complete_type_witness = %complete_type
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: !members:
  437. // CHECK:STDOUT: .Self = constants.%A
  438. // CHECK:STDOUT: }
  439. // CHECK:STDOUT:
  440. // CHECK:STDOUT: class @B {
  441. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete = constants.%empty_struct_type]
  442. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness %empty_struct_type [concrete = constants.%complete_type]
  443. // CHECK:STDOUT: complete_type_witness = %complete_type
  444. // CHECK:STDOUT:
  445. // CHECK:STDOUT: !members:
  446. // CHECK:STDOUT: .Self = constants.%B
  447. // CHECK:STDOUT: }
  448. // CHECK:STDOUT:
  449. // CHECK:STDOUT: generic fn @F(%T.loc9_6.1: %Generic.type.c7c) {
  450. // CHECK:STDOUT: %T.loc9_6.2: %Generic.type.c7c = bind_symbolic_name T, 0 [symbolic = %T.loc9_6.2 (constants.%T.a53)]
  451. // CHECK:STDOUT:
  452. // CHECK:STDOUT: fn();
  453. // CHECK:STDOUT: }
  454. // CHECK:STDOUT:
  455. // CHECK:STDOUT: generic fn @G(%T.loc10_6.1: %Generic.type.4ce) {
  456. // CHECK:STDOUT: %T.loc10_6.2: %Generic.type.4ce = bind_symbolic_name T, 0 [symbolic = %T.loc10_6.2 (constants.%T.bae)]
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: !definition:
  459. // CHECK:STDOUT:
  460. // CHECK:STDOUT: fn() {
  461. // CHECK:STDOUT: !entry:
  462. // CHECK:STDOUT: %F.ref: %F.type = name_ref F, file.%F.decl [concrete = constants.%F]
  463. // CHECK:STDOUT: %T.ref: %Generic.type.4ce = name_ref T, %T.loc10_6.1 [symbolic = %T.loc10_6.2 (constants.%T.bae)]
  464. // CHECK:STDOUT: return
  465. // CHECK:STDOUT: }
  466. // CHECK:STDOUT: }
  467. // CHECK:STDOUT:
  468. // CHECK:STDOUT: specific @Generic(constants.%T.8b3) {
  469. // CHECK:STDOUT: %T.loc4_19.2 => constants.%T.8b3
  470. // CHECK:STDOUT: }
  471. // CHECK:STDOUT:
  472. // CHECK:STDOUT: specific @Generic(constants.%A) {
  473. // CHECK:STDOUT: %T.loc4_19.2 => constants.%A
  474. // CHECK:STDOUT: }
  475. // CHECK:STDOUT:
  476. // CHECK:STDOUT: specific @F(constants.%T.a53) {
  477. // CHECK:STDOUT: %T.loc9_6.2 => constants.%T.a53
  478. // CHECK:STDOUT: }
  479. // CHECK:STDOUT:
  480. // CHECK:STDOUT: specific @Generic(constants.%B) {
  481. // CHECK:STDOUT: %T.loc4_19.2 => constants.%B
  482. // CHECK:STDOUT: }
  483. // CHECK:STDOUT:
  484. // CHECK:STDOUT: specific @G(constants.%T.bae) {
  485. // CHECK:STDOUT: %T.loc10_6.2 => constants.%T.bae
  486. // CHECK:STDOUT: }
  487. // CHECK:STDOUT: