method_deduce.carbon 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  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/class/generic/method_deduce.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/method_deduce.carbon
  10. class A {}
  11. class B {}
  12. class Class(T:! type) {
  13. fn Get(U:! type) -> (T, U) { return Get(U); }
  14. fn GetNoDeduce(x: T, U:! type) -> (T, U) { return GetNoDeduce(x, U); }
  15. }
  16. fn CallGenericMethod(c: Class(A)) -> (A, B) {
  17. return c.Get(B);
  18. }
  19. fn CallGenericMethodWithNonDeducedParam(c: Class(A)) -> (A, B) {
  20. return c.GetNoDeduce({}, B);
  21. }
  22. // CHECK:STDOUT: --- method_deduce.carbon
  23. // CHECK:STDOUT:
  24. // CHECK:STDOUT: constants {
  25. // CHECK:STDOUT: %A: type = class_type @A [template]
  26. // CHECK:STDOUT: %.1: type = struct_type {} [template]
  27. // CHECK:STDOUT: %.2: <witness> = complete_type_witness %.1 [template]
  28. // CHECK:STDOUT: %B: type = class_type @B [template]
  29. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic]
  30. // CHECK:STDOUT: %T.patt: type = symbolic_binding_pattern T, 0 [symbolic]
  31. // CHECK:STDOUT: %Class.type: type = generic_class_type @Class [template]
  32. // CHECK:STDOUT: %Class.1: %Class.type = struct_value () [template]
  33. // CHECK:STDOUT: %Class.2: type = class_type @Class, @Class(%T) [symbolic]
  34. // CHECK:STDOUT: %U: type = bind_symbolic_name U, 1 [symbolic]
  35. // CHECK:STDOUT: %U.patt: type = symbolic_binding_pattern U, 1 [symbolic]
  36. // CHECK:STDOUT: %tuple.type.1: type = tuple_type (type, type) [template]
  37. // CHECK:STDOUT: %tuple.type.2: type = tuple_type (%T, %U) [symbolic]
  38. // CHECK:STDOUT: %Get.type.1: type = fn_type @Get, @Class(%T) [symbolic]
  39. // CHECK:STDOUT: %Get.1: %Get.type.1 = struct_value () [symbolic]
  40. // CHECK:STDOUT: %GetNoDeduce.type.1: type = fn_type @GetNoDeduce, @Class(%T) [symbolic]
  41. // CHECK:STDOUT: %GetNoDeduce.1: %GetNoDeduce.type.1 = struct_value () [symbolic]
  42. // CHECK:STDOUT: %.4: <specific function> = specific_function %Get.1, @Get(%T, %U) [symbolic]
  43. // CHECK:STDOUT: %.5: <specific function> = specific_function %GetNoDeduce.1, @GetNoDeduce(%T, %U) [symbolic]
  44. // CHECK:STDOUT: %Class.3: type = class_type @Class, @Class(%A) [template]
  45. // CHECK:STDOUT: %tuple.type.3: type = tuple_type (%A, %B) [template]
  46. // CHECK:STDOUT: %CallGenericMethod.type: type = fn_type @CallGenericMethod [template]
  47. // CHECK:STDOUT: %CallGenericMethod: %CallGenericMethod.type = struct_value () [template]
  48. // CHECK:STDOUT: %Get.type.2: type = fn_type @Get, @Class(%A) [template]
  49. // CHECK:STDOUT: %Get.2: %Get.type.2 = struct_value () [template]
  50. // CHECK:STDOUT: %GetNoDeduce.type.2: type = fn_type @GetNoDeduce, @Class(%A) [template]
  51. // CHECK:STDOUT: %GetNoDeduce.2: %GetNoDeduce.type.2 = struct_value () [template]
  52. // CHECK:STDOUT: %.8: <specific function> = specific_function %Get.2, @Get(%A, %B) [template]
  53. // CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam.type: type = fn_type @CallGenericMethodWithNonDeducedParam [template]
  54. // CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam: %CallGenericMethodWithNonDeducedParam.type = struct_value () [template]
  55. // CHECK:STDOUT: %.9: <specific function> = specific_function %GetNoDeduce.2, @GetNoDeduce(%A, %B) [template]
  56. // CHECK:STDOUT: %struct: %A = struct_value () [template]
  57. // CHECK:STDOUT: }
  58. // CHECK:STDOUT:
  59. // CHECK:STDOUT: imports {
  60. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [template] {
  61. // CHECK:STDOUT: import Core//prelude
  62. // CHECK:STDOUT: import Core//prelude/...
  63. // CHECK:STDOUT: }
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT:
  66. // CHECK:STDOUT: file {
  67. // CHECK:STDOUT: package: <namespace> = namespace [template] {
  68. // CHECK:STDOUT: .Core = imports.%Core
  69. // CHECK:STDOUT: .A = %A.decl
  70. // CHECK:STDOUT: .B = %B.decl
  71. // CHECK:STDOUT: .Class = %Class.decl
  72. // CHECK:STDOUT: .CallGenericMethod = %CallGenericMethod.decl
  73. // CHECK:STDOUT: .CallGenericMethodWithNonDeducedParam = %CallGenericMethodWithNonDeducedParam.decl
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %Core.import = import Core
  76. // CHECK:STDOUT: %A.decl: type = class_decl @A [template = constants.%A] {} {}
  77. // CHECK:STDOUT: %B.decl: type = class_decl @B [template = constants.%B] {} {}
  78. // CHECK:STDOUT: %Class.decl: %Class.type = class_decl @Class [template = constants.%Class.1] {
  79. // CHECK:STDOUT: %T.patt.loc14_13.1: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc14_13.2 (constants.%T.patt)]
  80. // CHECK:STDOUT: %T.param_patt: type = value_param_pattern %T.patt.loc14_13.1, runtime_param<invalid> [symbolic = %T.patt.loc14_13.2 (constants.%T.patt)]
  81. // CHECK:STDOUT: } {
  82. // CHECK:STDOUT: %T.param: type = value_param runtime_param<invalid>
  83. // CHECK:STDOUT: %T.loc14_13.1: type = bind_symbolic_name T, 0, %T.param [symbolic = %T.loc14_13.2 (constants.%T)]
  84. // CHECK:STDOUT: }
  85. // CHECK:STDOUT: %CallGenericMethod.decl: %CallGenericMethod.type = fn_decl @CallGenericMethod [template = constants.%CallGenericMethod] {
  86. // CHECK:STDOUT: %c.patt: %Class.3 = binding_pattern c
  87. // CHECK:STDOUT: %c.param_patt: %Class.3 = value_param_pattern %c.patt, runtime_param0
  88. // CHECK:STDOUT: %return.patt: %tuple.type.3 = return_slot_pattern
  89. // CHECK:STDOUT: %return.param_patt: %tuple.type.3 = out_param_pattern %return.patt, runtime_param1
  90. // CHECK:STDOUT: } {
  91. // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1]
  92. // CHECK:STDOUT: %A.ref.loc19_31: type = name_ref A, file.%A.decl [template = constants.%A]
  93. // CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%A) [template = constants.%Class.3]
  94. // CHECK:STDOUT: %A.ref.loc19_39: type = name_ref A, file.%A.decl [template = constants.%A]
  95. // CHECK:STDOUT: %B.ref.loc19: type = name_ref B, file.%B.decl [template = constants.%B]
  96. // CHECK:STDOUT: %.loc19_43.1: %tuple.type.1 = tuple_literal (%A.ref.loc19_39, %B.ref.loc19)
  97. // CHECK:STDOUT: %.loc19_43.2: type = converted %.loc19_43.1, constants.%tuple.type.3 [template = constants.%tuple.type.3]
  98. // CHECK:STDOUT: %c.param: %Class.3 = value_param runtime_param0
  99. // CHECK:STDOUT: %c: %Class.3 = bind_name c, %c.param
  100. // CHECK:STDOUT: %return.param: ref %tuple.type.3 = out_param runtime_param1
  101. // CHECK:STDOUT: %return: ref %tuple.type.3 = return_slot %return.param
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: %CallGenericMethodWithNonDeducedParam.decl: %CallGenericMethodWithNonDeducedParam.type = fn_decl @CallGenericMethodWithNonDeducedParam [template = constants.%CallGenericMethodWithNonDeducedParam] {
  104. // CHECK:STDOUT: %c.patt: %Class.3 = binding_pattern c
  105. // CHECK:STDOUT: %c.param_patt: %Class.3 = value_param_pattern %c.patt, runtime_param0
  106. // CHECK:STDOUT: %return.patt: %tuple.type.3 = return_slot_pattern
  107. // CHECK:STDOUT: %return.param_patt: %tuple.type.3 = out_param_pattern %return.patt, runtime_param1
  108. // CHECK:STDOUT: } {
  109. // CHECK:STDOUT: %Class.ref: %Class.type = name_ref Class, file.%Class.decl [template = constants.%Class.1]
  110. // CHECK:STDOUT: %A.ref.loc23_50: type = name_ref A, file.%A.decl [template = constants.%A]
  111. // CHECK:STDOUT: %Class: type = class_type @Class, @Class(constants.%A) [template = constants.%Class.3]
  112. // CHECK:STDOUT: %A.ref.loc23_58: type = name_ref A, file.%A.decl [template = constants.%A]
  113. // CHECK:STDOUT: %B.ref.loc23: type = name_ref B, file.%B.decl [template = constants.%B]
  114. // CHECK:STDOUT: %.loc23_62.1: %tuple.type.1 = tuple_literal (%A.ref.loc23_58, %B.ref.loc23)
  115. // CHECK:STDOUT: %.loc23_62.2: type = converted %.loc23_62.1, constants.%tuple.type.3 [template = constants.%tuple.type.3]
  116. // CHECK:STDOUT: %c.param: %Class.3 = value_param runtime_param0
  117. // CHECK:STDOUT: %c: %Class.3 = bind_name c, %c.param
  118. // CHECK:STDOUT: %return.param: ref %tuple.type.3 = out_param runtime_param1
  119. // CHECK:STDOUT: %return: ref %tuple.type.3 = return_slot %return.param
  120. // CHECK:STDOUT: }
  121. // CHECK:STDOUT: }
  122. // CHECK:STDOUT:
  123. // CHECK:STDOUT: class @A {
  124. // CHECK:STDOUT: %.loc11: <witness> = complete_type_witness %.1 [template = constants.%.2]
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: !members:
  127. // CHECK:STDOUT: .Self = constants.%A
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: class @B {
  131. // CHECK:STDOUT: %.loc12: <witness> = complete_type_witness %.1 [template = constants.%.2]
  132. // CHECK:STDOUT:
  133. // CHECK:STDOUT: !members:
  134. // CHECK:STDOUT: .Self = constants.%B
  135. // CHECK:STDOUT: }
  136. // CHECK:STDOUT:
  137. // CHECK:STDOUT: generic class @Class(%T.loc14_13.1: type) {
  138. // CHECK:STDOUT: %T.loc14_13.2: type = bind_symbolic_name T, 0 [symbolic = %T.loc14_13.2 (constants.%T)]
  139. // CHECK:STDOUT: %T.patt.loc14_13.2: type = symbolic_binding_pattern T, 0 [symbolic = %T.patt.loc14_13.2 (constants.%T.patt)]
  140. // CHECK:STDOUT:
  141. // CHECK:STDOUT: !definition:
  142. // CHECK:STDOUT: %Get.type: type = fn_type @Get, @Class(%T.loc14_13.2) [symbolic = %Get.type (constants.%Get.type.1)]
  143. // CHECK:STDOUT: %Get: @Class.%Get.type (%Get.type.1) = struct_value () [symbolic = %Get (constants.%Get.1)]
  144. // CHECK:STDOUT: %GetNoDeduce.type: type = fn_type @GetNoDeduce, @Class(%T.loc14_13.2) [symbolic = %GetNoDeduce.type (constants.%GetNoDeduce.type.1)]
  145. // CHECK:STDOUT: %GetNoDeduce: @Class.%GetNoDeduce.type (%GetNoDeduce.type.1) = struct_value () [symbolic = %GetNoDeduce (constants.%GetNoDeduce.1)]
  146. // CHECK:STDOUT:
  147. // CHECK:STDOUT: class {
  148. // CHECK:STDOUT: %Get.decl: @Class.%Get.type (%Get.type.1) = fn_decl @Get [symbolic = @Class.%Get (constants.%Get.1)] {
  149. // CHECK:STDOUT: %U.patt.loc15_10.2: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc15_10.1 (constants.%U.patt)]
  150. // CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc15_10.2, runtime_param<invalid> [symbolic = %U.patt.loc15_10.1 (constants.%U.patt)]
  151. // CHECK:STDOUT: %return.patt: @Get.%tuple.type (%tuple.type.2) = return_slot_pattern
  152. // CHECK:STDOUT: %return.param_patt: @Get.%tuple.type (%tuple.type.2) = out_param_pattern %return.patt, runtime_param0
  153. // CHECK:STDOUT: } {
  154. // CHECK:STDOUT: %T.ref: type = name_ref T, @Class.%T.loc14_13.1 [symbolic = %T (constants.%T)]
  155. // CHECK:STDOUT: %U.ref.loc15_27: type = name_ref U, %U.loc15_10.2 [symbolic = %U.loc15_10.1 (constants.%U)]
  156. // CHECK:STDOUT: %.loc15_28.1: %tuple.type.1 = tuple_literal (%T.ref, %U.ref.loc15_27)
  157. // CHECK:STDOUT: %.loc15_28.2: type = converted %.loc15_28.1, constants.%tuple.type.2 [symbolic = %tuple.type (constants.%tuple.type.2)]
  158. // CHECK:STDOUT: %U.param: type = value_param runtime_param<invalid>
  159. // CHECK:STDOUT: %U.loc15_10.2: type = bind_symbolic_name U, 1, %U.param [symbolic = %U.loc15_10.1 (constants.%U)]
  160. // CHECK:STDOUT: %return.param: ref @Get.%tuple.type (%tuple.type.2) = out_param runtime_param0
  161. // CHECK:STDOUT: %return: ref @Get.%tuple.type (%tuple.type.2) = return_slot %return.param
  162. // CHECK:STDOUT: }
  163. // CHECK:STDOUT: %GetNoDeduce.decl: @Class.%GetNoDeduce.type (%GetNoDeduce.type.1) = fn_decl @GetNoDeduce [symbolic = @Class.%GetNoDeduce (constants.%GetNoDeduce.1)] {
  164. // CHECK:STDOUT: %x.patt: @GetNoDeduce.%T (%T) = binding_pattern x
  165. // CHECK:STDOUT: %x.param_patt: @GetNoDeduce.%T (%T) = value_param_pattern %x.patt, runtime_param0
  166. // CHECK:STDOUT: %U.patt.loc16_24.2: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc16_24.1 (constants.%U.patt)]
  167. // CHECK:STDOUT: %U.param_patt: type = value_param_pattern %U.patt.loc16_24.2, runtime_param<invalid> [symbolic = %U.patt.loc16_24.1 (constants.%U.patt)]
  168. // CHECK:STDOUT: %return.patt: @GetNoDeduce.%tuple.type (%tuple.type.2) = return_slot_pattern
  169. // CHECK:STDOUT: %return.param_patt: @GetNoDeduce.%tuple.type (%tuple.type.2) = out_param_pattern %return.patt, runtime_param1
  170. // CHECK:STDOUT: } {
  171. // CHECK:STDOUT: %T.ref.loc16_21: type = name_ref T, @Class.%T.loc14_13.1 [symbolic = %T (constants.%T)]
  172. // CHECK:STDOUT: %T.ref.loc16_38: type = name_ref T, @Class.%T.loc14_13.1 [symbolic = %T (constants.%T)]
  173. // CHECK:STDOUT: %U.ref.loc16_41: type = name_ref U, %U.loc16_24.2 [symbolic = %U.loc16_24.1 (constants.%U)]
  174. // CHECK:STDOUT: %.loc16_42.1: %tuple.type.1 = tuple_literal (%T.ref.loc16_38, %U.ref.loc16_41)
  175. // CHECK:STDOUT: %.loc16_42.2: type = converted %.loc16_42.1, constants.%tuple.type.2 [symbolic = %tuple.type (constants.%tuple.type.2)]
  176. // CHECK:STDOUT: %x.param: @GetNoDeduce.%T (%T) = value_param runtime_param0
  177. // CHECK:STDOUT: %x: @GetNoDeduce.%T (%T) = bind_name x, %x.param
  178. // CHECK:STDOUT: %U.param: type = value_param runtime_param<invalid>
  179. // CHECK:STDOUT: %U.loc16_24.2: type = bind_symbolic_name U, 1, %U.param [symbolic = %U.loc16_24.1 (constants.%U)]
  180. // CHECK:STDOUT: %return.param: ref @GetNoDeduce.%tuple.type (%tuple.type.2) = out_param runtime_param1
  181. // CHECK:STDOUT: %return: ref @GetNoDeduce.%tuple.type (%tuple.type.2) = return_slot %return.param
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT: %.loc17: <witness> = complete_type_witness %.1 [template = constants.%.2]
  184. // CHECK:STDOUT:
  185. // CHECK:STDOUT: !members:
  186. // CHECK:STDOUT: .Self = constants.%Class.2
  187. // CHECK:STDOUT: .Get = %Get.decl
  188. // CHECK:STDOUT: .GetNoDeduce = %GetNoDeduce.decl
  189. // CHECK:STDOUT: }
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: generic fn @Get(@Class.%T.loc14_13.1: type, %U.loc15_10.2: type) {
  193. // CHECK:STDOUT: %U.loc15_10.1: type = bind_symbolic_name U, 1 [symbolic = %U.loc15_10.1 (constants.%U)]
  194. // CHECK:STDOUT: %U.patt.loc15_10.1: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc15_10.1 (constants.%U.patt)]
  195. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  196. // CHECK:STDOUT: %tuple.type: type = tuple_type (@Get.%T (%T), @Get.%U.loc15_10.1 (%U)) [symbolic = %tuple.type (constants.%tuple.type.2)]
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: !definition:
  199. // CHECK:STDOUT: %Get.type: type = fn_type @Get, @Class(%T) [symbolic = %Get.type (constants.%Get.type.1)]
  200. // CHECK:STDOUT: %Get: @Get.%Get.type (%Get.type.1) = struct_value () [symbolic = %Get (constants.%Get.1)]
  201. // CHECK:STDOUT: %.loc15_39.3: <specific function> = specific_function %Get, @Get(%T, %U.loc15_10.1) [symbolic = %.loc15_39.3 (constants.%.4)]
  202. // CHECK:STDOUT:
  203. // CHECK:STDOUT: fn(%U.param_patt: type) -> %return: @Get.%tuple.type (%tuple.type.2) {
  204. // CHECK:STDOUT: !entry:
  205. // CHECK:STDOUT: %.loc15_39.1: @Get.%Get.type (%Get.type.1) = specific_constant @Class.%Get.decl, @Class(constants.%T) [symbolic = %Get (constants.%Get.1)]
  206. // CHECK:STDOUT: %Get.ref: @Get.%Get.type (%Get.type.1) = name_ref Get, %.loc15_39.1 [symbolic = %Get (constants.%Get.1)]
  207. // CHECK:STDOUT: %U.ref.loc15_43: type = name_ref U, %U.loc15_10.2 [symbolic = %U.loc15_10.1 (constants.%U)]
  208. // CHECK:STDOUT: %.loc15_39.2: <specific function> = specific_function %Get.ref, @Get(constants.%T, constants.%U) [symbolic = %.loc15_39.3 (constants.%.4)]
  209. // CHECK:STDOUT: %.loc15_42.1: ref @Get.%tuple.type (%tuple.type.2) = temporary_storage
  210. // CHECK:STDOUT: %Get.call: init @Get.%tuple.type (%tuple.type.2) = call %.loc15_39.2() to %.loc15_42.1
  211. // CHECK:STDOUT: %.loc15_42.2: ref @Get.%tuple.type (%tuple.type.2) = temporary %.loc15_42.1, %Get.call
  212. // CHECK:STDOUT: %.loc15_42.3: ref @Get.%T (%T) = tuple_access %.loc15_42.2, element0
  213. // CHECK:STDOUT: %.loc15_42.4: @Get.%T (%T) = bind_value %.loc15_42.3
  214. // CHECK:STDOUT: %.loc15_42.5: ref @Get.%T (%T) = tuple_access %return, element0
  215. // CHECK:STDOUT: %.loc15_42.6: init @Get.%T (%T) = initialize_from %.loc15_42.4 to %.loc15_42.5
  216. // CHECK:STDOUT: %.loc15_42.7: ref @Get.%U.loc15_10.1 (%U) = tuple_access %.loc15_42.2, element1
  217. // CHECK:STDOUT: %.loc15_42.8: @Get.%U.loc15_10.1 (%U) = bind_value %.loc15_42.7
  218. // CHECK:STDOUT: %.loc15_42.9: ref @Get.%U.loc15_10.1 (%U) = tuple_access %return, element1
  219. // CHECK:STDOUT: %.loc15_42.10: init @Get.%U.loc15_10.1 (%U) = initialize_from %.loc15_42.8 to %.loc15_42.9
  220. // CHECK:STDOUT: %.loc15_42.11: init @Get.%tuple.type (%tuple.type.2) = tuple_init (%.loc15_42.6, %.loc15_42.10) to %return
  221. // CHECK:STDOUT: %.loc15_45: init @Get.%tuple.type (%tuple.type.2) = converted %Get.call, %.loc15_42.11
  222. // CHECK:STDOUT: return %.loc15_45 to %return
  223. // CHECK:STDOUT: }
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT:
  226. // CHECK:STDOUT: generic fn @GetNoDeduce(@Class.%T.loc14_13.1: type, %U.loc16_24.2: type) {
  227. // CHECK:STDOUT: %T: type = bind_symbolic_name T, 0 [symbolic = %T (constants.%T)]
  228. // CHECK:STDOUT: %U.loc16_24.1: type = bind_symbolic_name U, 1 [symbolic = %U.loc16_24.1 (constants.%U)]
  229. // CHECK:STDOUT: %U.patt.loc16_24.1: type = symbolic_binding_pattern U, 1 [symbolic = %U.patt.loc16_24.1 (constants.%U.patt)]
  230. // CHECK:STDOUT: %tuple.type: type = tuple_type (@GetNoDeduce.%T (%T), @GetNoDeduce.%U.loc16_24.1 (%U)) [symbolic = %tuple.type (constants.%tuple.type.2)]
  231. // CHECK:STDOUT:
  232. // CHECK:STDOUT: !definition:
  233. // CHECK:STDOUT: %GetNoDeduce.type: type = fn_type @GetNoDeduce, @Class(%T) [symbolic = %GetNoDeduce.type (constants.%GetNoDeduce.type.1)]
  234. // CHECK:STDOUT: %GetNoDeduce: @GetNoDeduce.%GetNoDeduce.type (%GetNoDeduce.type.1) = struct_value () [symbolic = %GetNoDeduce (constants.%GetNoDeduce.1)]
  235. // CHECK:STDOUT: %.loc16_53.3: <specific function> = specific_function %GetNoDeduce, @GetNoDeduce(%T, %U.loc16_24.1) [symbolic = %.loc16_53.3 (constants.%.5)]
  236. // CHECK:STDOUT:
  237. // CHECK:STDOUT: fn(%x.param_patt: @GetNoDeduce.%T (%T), %U.param_patt: type) -> %return: @GetNoDeduce.%tuple.type (%tuple.type.2) {
  238. // CHECK:STDOUT: !entry:
  239. // CHECK:STDOUT: %.loc16_53.1: @GetNoDeduce.%GetNoDeduce.type (%GetNoDeduce.type.1) = specific_constant @Class.%GetNoDeduce.decl, @Class(constants.%T) [symbolic = %GetNoDeduce (constants.%GetNoDeduce.1)]
  240. // CHECK:STDOUT: %GetNoDeduce.ref: @GetNoDeduce.%GetNoDeduce.type (%GetNoDeduce.type.1) = name_ref GetNoDeduce, %.loc16_53.1 [symbolic = %GetNoDeduce (constants.%GetNoDeduce.1)]
  241. // CHECK:STDOUT: %x.ref: @GetNoDeduce.%T (%T) = name_ref x, %x
  242. // CHECK:STDOUT: %U.ref.loc16_68: type = name_ref U, %U.loc16_24.2 [symbolic = %U.loc16_24.1 (constants.%U)]
  243. // CHECK:STDOUT: %.loc16_53.2: <specific function> = specific_function %GetNoDeduce.ref, @GetNoDeduce(constants.%T, constants.%U) [symbolic = %.loc16_53.3 (constants.%.5)]
  244. // CHECK:STDOUT: %.loc16_64.1: ref @GetNoDeduce.%tuple.type (%tuple.type.2) = temporary_storage
  245. // CHECK:STDOUT: %GetNoDeduce.call: init @GetNoDeduce.%tuple.type (%tuple.type.2) = call %.loc16_53.2(%x.ref) to %.loc16_64.1
  246. // CHECK:STDOUT: %.loc16_64.2: ref @GetNoDeduce.%tuple.type (%tuple.type.2) = temporary %.loc16_64.1, %GetNoDeduce.call
  247. // CHECK:STDOUT: %.loc16_64.3: ref @GetNoDeduce.%T (%T) = tuple_access %.loc16_64.2, element0
  248. // CHECK:STDOUT: %.loc16_64.4: @GetNoDeduce.%T (%T) = bind_value %.loc16_64.3
  249. // CHECK:STDOUT: %.loc16_64.5: ref @GetNoDeduce.%T (%T) = tuple_access %return, element0
  250. // CHECK:STDOUT: %.loc16_64.6: init @GetNoDeduce.%T (%T) = initialize_from %.loc16_64.4 to %.loc16_64.5
  251. // CHECK:STDOUT: %.loc16_64.7: ref @GetNoDeduce.%U.loc16_24.1 (%U) = tuple_access %.loc16_64.2, element1
  252. // CHECK:STDOUT: %.loc16_64.8: @GetNoDeduce.%U.loc16_24.1 (%U) = bind_value %.loc16_64.7
  253. // CHECK:STDOUT: %.loc16_64.9: ref @GetNoDeduce.%U.loc16_24.1 (%U) = tuple_access %return, element1
  254. // CHECK:STDOUT: %.loc16_64.10: init @GetNoDeduce.%U.loc16_24.1 (%U) = initialize_from %.loc16_64.8 to %.loc16_64.9
  255. // CHECK:STDOUT: %.loc16_64.11: init @GetNoDeduce.%tuple.type (%tuple.type.2) = tuple_init (%.loc16_64.6, %.loc16_64.10) to %return
  256. // CHECK:STDOUT: %.loc16_70: init @GetNoDeduce.%tuple.type (%tuple.type.2) = converted %GetNoDeduce.call, %.loc16_64.11
  257. // CHECK:STDOUT: return %.loc16_70 to %return
  258. // CHECK:STDOUT: }
  259. // CHECK:STDOUT: }
  260. // CHECK:STDOUT:
  261. // CHECK:STDOUT: fn @CallGenericMethod(%c.param_patt: %Class.3) -> %return: %tuple.type.3 {
  262. // CHECK:STDOUT: !entry:
  263. // CHECK:STDOUT: %c.ref: %Class.3 = name_ref c, %c
  264. // CHECK:STDOUT: %.loc20_11.1: %Get.type.2 = specific_constant @Class.%Get.decl, @Class(constants.%A) [template = constants.%Get.2]
  265. // CHECK:STDOUT: %Get.ref: %Get.type.2 = name_ref Get, %.loc20_11.1 [template = constants.%Get.2]
  266. // CHECK:STDOUT: %B.ref.loc20: type = name_ref B, file.%B.decl [template = constants.%B]
  267. // CHECK:STDOUT: %.loc20_11.2: <specific function> = specific_function %Get.ref, @Get(constants.%A, constants.%B) [template = constants.%.8]
  268. // CHECK:STDOUT: %.loc19_35.2: ref %tuple.type.3 = splice_block %return {}
  269. // CHECK:STDOUT: %Get.call: init %tuple.type.3 = call %.loc20_11.2() to %.loc19_35.2
  270. // CHECK:STDOUT: return %Get.call to %return
  271. // CHECK:STDOUT: }
  272. // CHECK:STDOUT:
  273. // CHECK:STDOUT: fn @CallGenericMethodWithNonDeducedParam(%c.param_patt: %Class.3) -> %return: %tuple.type.3 {
  274. // CHECK:STDOUT: !entry:
  275. // CHECK:STDOUT: %c.ref: %Class.3 = name_ref c, %c
  276. // CHECK:STDOUT: %.loc24_11.1: %GetNoDeduce.type.2 = specific_constant @Class.%GetNoDeduce.decl, @Class(constants.%A) [template = constants.%GetNoDeduce.2]
  277. // CHECK:STDOUT: %GetNoDeduce.ref: %GetNoDeduce.type.2 = name_ref GetNoDeduce, %.loc24_11.1 [template = constants.%GetNoDeduce.2]
  278. // CHECK:STDOUT: %.loc24_25.1: %.1 = struct_literal ()
  279. // CHECK:STDOUT: %B.ref.loc24: type = name_ref B, file.%B.decl [template = constants.%B]
  280. // CHECK:STDOUT: %.loc24_11.2: <specific function> = specific_function %GetNoDeduce.ref, @GetNoDeduce(constants.%A, constants.%B) [template = constants.%.9]
  281. // CHECK:STDOUT: %.loc23_54.2: ref %tuple.type.3 = splice_block %return {}
  282. // CHECK:STDOUT: %.loc24_25.2: ref %A = temporary_storage
  283. // CHECK:STDOUT: %.loc24_25.3: init %A = class_init (), %.loc24_25.2 [template = constants.%struct]
  284. // CHECK:STDOUT: %.loc24_25.4: ref %A = temporary %.loc24_25.2, %.loc24_25.3
  285. // CHECK:STDOUT: %.loc24_25.5: ref %A = converted %.loc24_25.1, %.loc24_25.4
  286. // CHECK:STDOUT: %.loc24_25.6: %A = bind_value %.loc24_25.5
  287. // CHECK:STDOUT: %GetNoDeduce.call: init %tuple.type.3 = call %.loc24_11.2(%.loc24_25.6) to %.loc23_54.2
  288. // CHECK:STDOUT: return %GetNoDeduce.call to %return
  289. // CHECK:STDOUT: }
  290. // CHECK:STDOUT:
  291. // CHECK:STDOUT: specific @Class(constants.%T) {
  292. // CHECK:STDOUT: %T.loc14_13.2 => constants.%T
  293. // CHECK:STDOUT: %T.patt.loc14_13.2 => constants.%T
  294. // CHECK:STDOUT:
  295. // CHECK:STDOUT: !definition:
  296. // CHECK:STDOUT: %Get.type => constants.%Get.type.1
  297. // CHECK:STDOUT: %Get => constants.%Get.1
  298. // CHECK:STDOUT: %GetNoDeduce.type => constants.%GetNoDeduce.type.1
  299. // CHECK:STDOUT: %GetNoDeduce => constants.%GetNoDeduce.1
  300. // CHECK:STDOUT: }
  301. // CHECK:STDOUT:
  302. // CHECK:STDOUT: specific @Get(constants.%T, constants.%U) {
  303. // CHECK:STDOUT: %U.loc15_10.1 => constants.%U
  304. // CHECK:STDOUT: %U.patt.loc15_10.1 => constants.%U
  305. // CHECK:STDOUT: %T => constants.%T
  306. // CHECK:STDOUT: %tuple.type => constants.%tuple.type.2
  307. // CHECK:STDOUT:
  308. // CHECK:STDOUT: !definition:
  309. // CHECK:STDOUT: %Get.type => constants.%Get.type.1
  310. // CHECK:STDOUT: %Get => constants.%Get.1
  311. // CHECK:STDOUT: %.loc15_39.3 => constants.%.4
  312. // CHECK:STDOUT: }
  313. // CHECK:STDOUT:
  314. // CHECK:STDOUT: specific @GetNoDeduce(constants.%T, constants.%U) {
  315. // CHECK:STDOUT: %T => constants.%T
  316. // CHECK:STDOUT: %U.loc16_24.1 => constants.%U
  317. // CHECK:STDOUT: %U.patt.loc16_24.1 => constants.%U
  318. // CHECK:STDOUT: %tuple.type => constants.%tuple.type.2
  319. // CHECK:STDOUT:
  320. // CHECK:STDOUT: !definition:
  321. // CHECK:STDOUT: %GetNoDeduce.type => constants.%GetNoDeduce.type.1
  322. // CHECK:STDOUT: %GetNoDeduce => constants.%GetNoDeduce.1
  323. // CHECK:STDOUT: %.loc16_53.3 => constants.%.5
  324. // CHECK:STDOUT: }
  325. // CHECK:STDOUT:
  326. // CHECK:STDOUT: specific @Class(%T.loc14_13.2) {
  327. // CHECK:STDOUT: %T.loc14_13.2 => constants.%T
  328. // CHECK:STDOUT: %T.patt.loc14_13.2 => constants.%T
  329. // CHECK:STDOUT: }
  330. // CHECK:STDOUT:
  331. // CHECK:STDOUT: specific @Class(@Get.%T) {
  332. // CHECK:STDOUT: %T.loc14_13.2 => constants.%T
  333. // CHECK:STDOUT: %T.patt.loc14_13.2 => constants.%T
  334. // CHECK:STDOUT: }
  335. // CHECK:STDOUT:
  336. // CHECK:STDOUT: specific @Get(%T, %U.loc15_10.1) {
  337. // CHECK:STDOUT: %U.loc15_10.1 => constants.%U
  338. // CHECK:STDOUT: %U.patt.loc15_10.1 => constants.%U
  339. // CHECK:STDOUT: %T => constants.%T
  340. // CHECK:STDOUT: %tuple.type => constants.%tuple.type.2
  341. // CHECK:STDOUT: }
  342. // CHECK:STDOUT:
  343. // CHECK:STDOUT: specific @Class(@GetNoDeduce.%T) {
  344. // CHECK:STDOUT: %T.loc14_13.2 => constants.%T
  345. // CHECK:STDOUT: %T.patt.loc14_13.2 => constants.%T
  346. // CHECK:STDOUT: }
  347. // CHECK:STDOUT:
  348. // CHECK:STDOUT: specific @GetNoDeduce(%T, %U.loc16_24.1) {
  349. // CHECK:STDOUT: %T => constants.%T
  350. // CHECK:STDOUT: %U.loc16_24.1 => constants.%U
  351. // CHECK:STDOUT: %U.patt.loc16_24.1 => constants.%U
  352. // CHECK:STDOUT: %tuple.type => constants.%tuple.type.2
  353. // CHECK:STDOUT: }
  354. // CHECK:STDOUT:
  355. // CHECK:STDOUT: specific @Class(constants.%A) {
  356. // CHECK:STDOUT: %T.loc14_13.2 => constants.%A
  357. // CHECK:STDOUT: %T.patt.loc14_13.2 => constants.%A
  358. // CHECK:STDOUT:
  359. // CHECK:STDOUT: !definition:
  360. // CHECK:STDOUT: %Get.type => constants.%Get.type.2
  361. // CHECK:STDOUT: %Get => constants.%Get.2
  362. // CHECK:STDOUT: %GetNoDeduce.type => constants.%GetNoDeduce.type.2
  363. // CHECK:STDOUT: %GetNoDeduce => constants.%GetNoDeduce.2
  364. // CHECK:STDOUT: }
  365. // CHECK:STDOUT:
  366. // CHECK:STDOUT: specific @Get(constants.%A, constants.%B) {
  367. // CHECK:STDOUT: %U.loc15_10.1 => constants.%B
  368. // CHECK:STDOUT: %U.patt.loc15_10.1 => constants.%B
  369. // CHECK:STDOUT: %T => constants.%A
  370. // CHECK:STDOUT: %tuple.type => constants.%tuple.type.3
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: !definition:
  373. // CHECK:STDOUT: %Get.type => constants.%Get.type.2
  374. // CHECK:STDOUT: %Get => constants.%Get.2
  375. // CHECK:STDOUT: %.loc15_39.3 => constants.%.8
  376. // CHECK:STDOUT: }
  377. // CHECK:STDOUT:
  378. // CHECK:STDOUT: specific @GetNoDeduce(constants.%A, constants.%B) {
  379. // CHECK:STDOUT: %T => constants.%A
  380. // CHECK:STDOUT: %U.loc16_24.1 => constants.%B
  381. // CHECK:STDOUT: %U.patt.loc16_24.1 => constants.%B
  382. // CHECK:STDOUT: %tuple.type => constants.%tuple.type.3
  383. // CHECK:STDOUT:
  384. // CHECK:STDOUT: !definition:
  385. // CHECK:STDOUT: %GetNoDeduce.type => constants.%GetNoDeduce.type.2
  386. // CHECK:STDOUT: %GetNoDeduce => constants.%GetNoDeduce.2
  387. // CHECK:STDOUT: %.loc16_53.3 => constants.%.9
  388. // CHECK:STDOUT: }
  389. // CHECK:STDOUT: