method.carbon 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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/int.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/function/builtin/method.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/function/builtin/method.carbon
  14. interface I {
  15. fn F[self: Self](other: Self) -> Self;
  16. }
  17. impl i32 as I {
  18. fn F[self: i32](other: i32) -> i32 = "int.sadd";
  19. }
  20. var arr: array(i32, (1 as i32).(I.F)(2));
  21. // CHECK:STDOUT: --- method.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  25. // CHECK:STDOUT: %Self.ab9: %I.type = symbolic_binding Self, 0 [symbolic]
  26. // CHECK:STDOUT: %Self.binding.as_type.d31: type = symbolic_binding_type Self, 0, %Self.ab9 [symbolic]
  27. // CHECK:STDOUT: %pattern_type.fa0: type = pattern_type %Self.binding.as_type.d31 [symbolic]
  28. // CHECK:STDOUT: %.e46: Core.Form = init_form %Self.binding.as_type.d31 [symbolic]
  29. // CHECK:STDOUT: %I.WithSelf.F.type.08c: type = fn_type @I.WithSelf.F, @I.WithSelf(%Self.ab9) [symbolic]
  30. // CHECK:STDOUT: %I.WithSelf.F.705: %I.WithSelf.F.type.08c = struct_value () [symbolic]
  31. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  32. // CHECK:STDOUT: %assoc0.18e: %I.assoc_type = assoc_entity element0, @I.WithSelf.%I.WithSelf.F.decl [concrete]
  33. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  34. // CHECK:STDOUT: %Int.type: type = generic_class_type @Int [concrete]
  35. // CHECK:STDOUT: %Int.generic: %Int.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %i32: type = class_type @Int, @Int(%int_32) [concrete]
  37. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness @i32.as.I.impl.%I.impl_witness_table [concrete]
  38. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  39. // CHECK:STDOUT: %.ff5: Core.Form = init_form %i32 [concrete]
  40. // CHECK:STDOUT: %i32.as.I.impl.F.type: type = fn_type @i32.as.I.impl.F [concrete]
  41. // CHECK:STDOUT: %i32.as.I.impl.F: %i32.as.I.impl.F.type = struct_value () [concrete]
  42. // CHECK:STDOUT: %I.facet: %I.type = facet_value %i32, (%I.impl_witness) [concrete]
  43. // CHECK:STDOUT: %I.WithSelf.F.type.f37: type = fn_type @I.WithSelf.F, @I.WithSelf(%I.facet) [concrete]
  44. // CHECK:STDOUT: %I.WithSelf.F.b05: %I.WithSelf.F.type.f37 = struct_value () [concrete]
  45. // CHECK:STDOUT: %int_1.5b8: Core.IntLiteral = int_value 1 [concrete]
  46. // CHECK:STDOUT: %As.type.90f: type = generic_interface_type @As [concrete]
  47. // CHECK:STDOUT: %As.generic: %As.type.90f = struct_value () [concrete]
  48. // CHECK:STDOUT: %As.type.047: type = facet_type <@As, @As(%i32)> [concrete]
  49. // CHECK:STDOUT: %To: Core.IntLiteral = symbolic_binding To, 0 [symbolic]
  50. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.09e: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%To) [symbolic]
  51. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.dbe: %Core.IntLiteral.as.As.impl.Convert.type.09e = struct_value () [symbolic]
  52. // CHECK:STDOUT: %From: Core.IntLiteral = symbolic_binding From, 0 [symbolic]
  53. // CHECK:STDOUT: %As.impl_witness.ab6: <witness> = impl_witness imports.%As.impl_witness_table.9fc, @Core.IntLiteral.as.As.impl(%int_32) [concrete]
  54. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.type.8ec: type = fn_type @Core.IntLiteral.as.As.impl.Convert, @Core.IntLiteral.as.As.impl(%int_32) [concrete]
  55. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.29b: %Core.IntLiteral.as.As.impl.Convert.type.8ec = struct_value () [concrete]
  56. // CHECK:STDOUT: %As.facet: %As.type.047 = facet_value Core.IntLiteral, (%As.impl_witness.ab6) [concrete]
  57. // CHECK:STDOUT: %As.WithSelf.Convert.type.e5b: type = fn_type @As.WithSelf.Convert, @As.WithSelf(%i32, %As.facet) [concrete]
  58. // CHECK:STDOUT: %.9ed: type = fn_type_with_self_type %As.WithSelf.Convert.type.e5b, %As.facet [concrete]
  59. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.bound: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.29b [concrete]
  60. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.As.impl.Convert.29b, @Core.IntLiteral.as.As.impl.Convert(%int_32) [concrete]
  61. // CHECK:STDOUT: %bound_method.290: <bound method> = bound_method %int_1.5b8, %Core.IntLiteral.as.As.impl.Convert.specific_fn [concrete]
  62. // CHECK:STDOUT: %int_1.5d2: %i32 = int_value 1 [concrete]
  63. // CHECK:STDOUT: %.131: type = fn_type_with_self_type %I.WithSelf.F.type.f37, %I.facet [concrete]
  64. // CHECK:STDOUT: %i32.as.I.impl.F.bound: <bound method> = bound_method %int_1.5d2, %i32.as.I.impl.F [concrete]
  65. // CHECK:STDOUT: %int_2.ecc: Core.IntLiteral = int_value 2 [concrete]
  66. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  67. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  68. // CHECK:STDOUT: %ImplicitAs.type.e8c: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  69. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  70. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6 = struct_value () [symbolic]
  71. // CHECK:STDOUT: %ImplicitAs.type.139: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
  72. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.type.2ed: type = fn_type @Int.as.ImplicitAs.impl.Convert, @Int.as.ImplicitAs.impl(%From) [symbolic]
  73. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.d29: %Int.as.ImplicitAs.impl.Convert.type.2ed = struct_value () [symbolic]
  74. // CHECK:STDOUT: %ImplicitAs.impl_witness.6bc: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.74f, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  75. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  76. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.e0d = struct_value () [concrete]
  77. // CHECK:STDOUT: %ImplicitAs.facet.b94: %ImplicitAs.type.e8c = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.6bc) [concrete]
  78. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.b37: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(%i32, %ImplicitAs.facet.b94) [concrete]
  79. // CHECK:STDOUT: %.545: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.b37, %ImplicitAs.facet.b94 [concrete]
  80. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5 [concrete]
  81. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  82. // CHECK:STDOUT: %bound_method.646: <bound method> = bound_method %int_2.ecc, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  83. // CHECK:STDOUT: %int_2.ef8: %i32 = int_value 2 [concrete]
  84. // CHECK:STDOUT: %int_3.822: %i32 = int_value 3 [concrete]
  85. // CHECK:STDOUT: %ImplicitAs.impl_witness.640: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.ea2, @Int.as.ImplicitAs.impl(%int_32) [concrete]
  86. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.type.240: type = fn_type @Int.as.ImplicitAs.impl.Convert, @Int.as.ImplicitAs.impl(%int_32) [concrete]
  87. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.dd4: %Int.as.ImplicitAs.impl.Convert.type.240 = struct_value () [concrete]
  88. // CHECK:STDOUT: %ImplicitAs.facet.290: %ImplicitAs.type.139 = facet_value %i32, (%ImplicitAs.impl_witness.640) [concrete]
  89. // CHECK:STDOUT: %ImplicitAs.WithSelf.Convert.type.462: type = fn_type @ImplicitAs.WithSelf.Convert, @ImplicitAs.WithSelf(Core.IntLiteral, %ImplicitAs.facet.290) [concrete]
  90. // CHECK:STDOUT: %.0a7: type = fn_type_with_self_type %ImplicitAs.WithSelf.Convert.type.462, %ImplicitAs.facet.290 [concrete]
  91. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_3.822, %Int.as.ImplicitAs.impl.Convert.dd4 [concrete]
  92. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Int.as.ImplicitAs.impl.Convert.dd4, @Int.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  93. // CHECK:STDOUT: %bound_method.17a: <bound method> = bound_method %int_3.822, %Int.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  94. // CHECK:STDOUT: %int_3.1ba: Core.IntLiteral = int_value 3 [concrete]
  95. // CHECK:STDOUT: %array_type: type = array_type %int_3.1ba, %i32 [concrete]
  96. // CHECK:STDOUT: %pattern_type.5d8: type = pattern_type %array_type [concrete]
  97. // CHECK:STDOUT: %DefaultOrUnformed.type: type = facet_type <@DefaultOrUnformed> [concrete]
  98. // CHECK:STDOUT: %T.67d: type = symbolic_binding T, 0 [symbolic]
  99. // CHECK:STDOUT: %T.as.DefaultOrUnformed.impl.Op.type.6c6: type = fn_type @T.as.DefaultOrUnformed.impl.Op, @T.as.DefaultOrUnformed.impl(%T.67d) [symbolic]
  100. // CHECK:STDOUT: %T.as.DefaultOrUnformed.impl.Op.ae1: %T.as.DefaultOrUnformed.impl.Op.type.6c6 = struct_value () [symbolic]
  101. // CHECK:STDOUT: %DefaultOrUnformed.impl_witness.d11: <witness> = impl_witness imports.%DefaultOrUnformed.impl_witness_table.349, @T.as.DefaultOrUnformed.impl(%array_type) [concrete]
  102. // CHECK:STDOUT: %T.as.DefaultOrUnformed.impl.Op.type.576: type = fn_type @T.as.DefaultOrUnformed.impl.Op, @T.as.DefaultOrUnformed.impl(%array_type) [concrete]
  103. // CHECK:STDOUT: %T.as.DefaultOrUnformed.impl.Op.9c0: %T.as.DefaultOrUnformed.impl.Op.type.576 = struct_value () [concrete]
  104. // CHECK:STDOUT: %DefaultOrUnformed.facet: %DefaultOrUnformed.type = facet_value %array_type, (%DefaultOrUnformed.impl_witness.d11) [concrete]
  105. // CHECK:STDOUT: %T.as.DefaultOrUnformed.impl.Op.specific_fn: <specific function> = specific_function %T.as.DefaultOrUnformed.impl.Op.9c0, @T.as.DefaultOrUnformed.impl.Op(%array_type) [concrete]
  106. // CHECK:STDOUT: }
  107. // CHECK:STDOUT:
  108. // CHECK:STDOUT: imports {
  109. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  110. // CHECK:STDOUT: .Int = %Core.Int
  111. // CHECK:STDOUT: .As = %Core.As
  112. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  113. // CHECK:STDOUT: .DefaultOrUnformed = %Core.DefaultOrUnformed
  114. // CHECK:STDOUT: import Core//prelude
  115. // CHECK:STDOUT: import Core//prelude/...
  116. // CHECK:STDOUT: }
  117. // CHECK:STDOUT: %Core.Int: %Int.type = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  118. // CHECK:STDOUT: %Core.As: %As.type.90f = import_ref Core//prelude/parts/as, As, loaded [concrete = constants.%As.generic]
  119. // CHECK:STDOUT: %Core.import_ref.ca0: @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert.type (%Core.IntLiteral.as.As.impl.Convert.type.09e) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.As.impl.%Core.IntLiteral.as.As.impl.Convert (constants.%Core.IntLiteral.as.As.impl.Convert.dbe)]
  120. // CHECK:STDOUT: %As.impl_witness_table.9fc = impl_witness_table (%Core.import_ref.ca0), @Core.IntLiteral.as.As.impl [concrete]
  121. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  122. // CHECK:STDOUT: %Core.import_ref.42d: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.4e6) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.3c2)]
  123. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.74f = impl_witness_table (%Core.import_ref.42d), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  124. // CHECK:STDOUT: %Core.import_ref.0bc: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.2ed) = import_ref Core//prelude/parts/int, loc{{\d+_\d+}}, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.d29)]
  125. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.ea2 = impl_witness_table (%Core.import_ref.0bc), @Int.as.ImplicitAs.impl [concrete]
  126. // CHECK:STDOUT: %Core.DefaultOrUnformed: type = import_ref Core//prelude/parts/default, DefaultOrUnformed, loaded [concrete = constants.%DefaultOrUnformed.type]
  127. // CHECK:STDOUT: %Core.import_ref.01d: @T.as.DefaultOrUnformed.impl.%T.as.DefaultOrUnformed.impl.Op.type (%T.as.DefaultOrUnformed.impl.Op.type.6c6) = import_ref Core//prelude/parts/default, loc{{\d+_\d+}}, loaded [symbolic = @T.as.DefaultOrUnformed.impl.%T.as.DefaultOrUnformed.impl.Op (constants.%T.as.DefaultOrUnformed.impl.Op.ae1)]
  128. // CHECK:STDOUT: %DefaultOrUnformed.impl_witness_table.349 = impl_witness_table (%Core.import_ref.01d), @T.as.DefaultOrUnformed.impl [concrete]
  129. // CHECK:STDOUT: }
  130. // CHECK:STDOUT:
  131. // CHECK:STDOUT: file {
  132. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  133. // CHECK:STDOUT: .Core = imports.%Core
  134. // CHECK:STDOUT: .I = %I.decl
  135. // CHECK:STDOUT: .arr = %arr
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT: %Core.import = import Core
  138. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  139. // CHECK:STDOUT: impl_decl @i32.as.I.impl [concrete] {} {
  140. // CHECK:STDOUT: %i32: type = type_literal constants.%i32 [concrete = constants.%i32]
  141. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT: name_binding_decl {
  144. // CHECK:STDOUT: %arr.patt: %pattern_type.5d8 = ref_binding_pattern arr [concrete]
  145. // CHECK:STDOUT: %arr.var_patt: %pattern_type.5d8 = var_pattern %arr.patt [concrete]
  146. // CHECK:STDOUT: }
  147. // CHECK:STDOUT: %arr.var: ref %array_type = var %arr.var_patt [concrete]
  148. // CHECK:STDOUT: %.loc23_40: type = splice_block %array_type [concrete = constants.%array_type] {
  149. // CHECK:STDOUT: %i32.loc23_16: type = type_literal constants.%i32 [concrete = constants.%i32]
  150. // CHECK:STDOUT: %int_1: Core.IntLiteral = int_value 1 [concrete = constants.%int_1.5b8]
  151. // CHECK:STDOUT: %i32.loc23_27: type = type_literal constants.%i32 [concrete = constants.%i32]
  152. // CHECK:STDOUT: %impl.elem0.loc23_24: %.9ed = impl_witness_access constants.%As.impl_witness.ab6, element0 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.29b]
  153. // CHECK:STDOUT: %bound_method.loc23_24.1: <bound method> = bound_method %int_1, %impl.elem0.loc23_24 [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.bound]
  154. // CHECK:STDOUT: %specific_fn.loc23_24: <specific function> = specific_function %impl.elem0.loc23_24, @Core.IntLiteral.as.As.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.As.impl.Convert.specific_fn]
  155. // CHECK:STDOUT: %bound_method.loc23_24.2: <bound method> = bound_method %int_1, %specific_fn.loc23_24 [concrete = constants.%bound_method.290]
  156. // CHECK:STDOUT: %Core.IntLiteral.as.As.impl.Convert.call: init %i32 = call %bound_method.loc23_24.2(%int_1) [concrete = constants.%int_1.5d2]
  157. // CHECK:STDOUT: %.loc23_24.1: %i32 = value_of_initializer %Core.IntLiteral.as.As.impl.Convert.call [concrete = constants.%int_1.5d2]
  158. // CHECK:STDOUT: %.loc23_24.2: %i32 = converted %int_1, %.loc23_24.1 [concrete = constants.%int_1.5d2]
  159. // CHECK:STDOUT: %I.ref: type = name_ref I, %I.decl [concrete = constants.%I.type]
  160. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.WithSelf.%assoc0 [concrete = constants.%assoc0.18e]
  161. // CHECK:STDOUT: %impl.elem0.loc23_31: %.131 = impl_witness_access constants.%I.impl_witness, element0 [concrete = constants.%i32.as.I.impl.F]
  162. // CHECK:STDOUT: %bound_method.loc23_31: <bound method> = bound_method %.loc23_24.2, %impl.elem0.loc23_31 [concrete = constants.%i32.as.I.impl.F.bound]
  163. // CHECK:STDOUT: %int_2: Core.IntLiteral = int_value 2 [concrete = constants.%int_2.ecc]
  164. // CHECK:STDOUT: %impl.elem0.loc23_38: %.545 = impl_witness_access constants.%ImplicitAs.impl_witness.6bc, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.0b5]
  165. // CHECK:STDOUT: %bound_method.loc23_38.1: <bound method> = bound_method %int_2, %impl.elem0.loc23_38 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  166. // CHECK:STDOUT: %specific_fn.loc23_38: <specific function> = specific_function %impl.elem0.loc23_38, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  167. // CHECK:STDOUT: %bound_method.loc23_38.2: <bound method> = bound_method %int_2, %specific_fn.loc23_38 [concrete = constants.%bound_method.646]
  168. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc23_38.2(%int_2) [concrete = constants.%int_2.ef8]
  169. // CHECK:STDOUT: %.loc23_38.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_2.ef8]
  170. // CHECK:STDOUT: %.loc23_38.2: %i32 = converted %int_2, %.loc23_38.1 [concrete = constants.%int_2.ef8]
  171. // CHECK:STDOUT: %i32.as.I.impl.F.call: init %i32 = call %bound_method.loc23_31(%.loc23_24.2, %.loc23_38.2) [concrete = constants.%int_3.822]
  172. // CHECK:STDOUT: %impl.elem0.loc23_39: %.0a7 = impl_witness_access constants.%ImplicitAs.impl_witness.640, element0 [concrete = constants.%Int.as.ImplicitAs.impl.Convert.dd4]
  173. // CHECK:STDOUT: %bound_method.loc23_39.1: <bound method> = bound_method %i32.as.I.impl.F.call, %impl.elem0.loc23_39 [concrete = constants.%Int.as.ImplicitAs.impl.Convert.bound]
  174. // CHECK:STDOUT: %specific_fn.loc23_39: <specific function> = specific_function %impl.elem0.loc23_39, @Int.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Int.as.ImplicitAs.impl.Convert.specific_fn]
  175. // CHECK:STDOUT: %bound_method.loc23_39.2: <bound method> = bound_method %i32.as.I.impl.F.call, %specific_fn.loc23_39 [concrete = constants.%bound_method.17a]
  176. // CHECK:STDOUT: %.loc23_39.1: %i32 = value_of_initializer %i32.as.I.impl.F.call [concrete = constants.%int_3.822]
  177. // CHECK:STDOUT: %.loc23_39.2: %i32 = converted %i32.as.I.impl.F.call, %.loc23_39.1 [concrete = constants.%int_3.822]
  178. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.call: init Core.IntLiteral = call %bound_method.loc23_39.2(%.loc23_39.2) [concrete = constants.%int_3.1ba]
  179. // CHECK:STDOUT: %.loc23_39.3: Core.IntLiteral = value_of_initializer %Int.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_3.1ba]
  180. // CHECK:STDOUT: %.loc23_39.4: Core.IntLiteral = converted %i32.as.I.impl.F.call, %.loc23_39.3 [concrete = constants.%int_3.1ba]
  181. // CHECK:STDOUT: %array_type: type = array_type %.loc23_39.4, %i32.loc23_16 [concrete = constants.%array_type]
  182. // CHECK:STDOUT: }
  183. // CHECK:STDOUT: %arr: ref %array_type = ref_binding arr, %arr.var [concrete = %arr.var]
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: interface @I {
  187. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self.ab9]
  188. // CHECK:STDOUT: %I.WithSelf.decl = interface_with_self_decl @I [concrete]
  189. // CHECK:STDOUT:
  190. // CHECK:STDOUT: !with Self:
  191. // CHECK:STDOUT: %I.WithSelf.F.decl: @I.WithSelf.%I.WithSelf.F.type (%I.WithSelf.F.type.08c) = fn_decl @I.WithSelf.F [symbolic = @I.WithSelf.%I.WithSelf.F (constants.%I.WithSelf.F.705)] {
  192. // CHECK:STDOUT: %self.param_patt: @I.WithSelf.F.%pattern_type (%pattern_type.fa0) = value_param_pattern [concrete]
  193. // CHECK:STDOUT: %self.patt: @I.WithSelf.F.%pattern_type (%pattern_type.fa0) = at_binding_pattern self, %self.param_patt [concrete]
  194. // CHECK:STDOUT: %other.param_patt: @I.WithSelf.F.%pattern_type (%pattern_type.fa0) = value_param_pattern [concrete]
  195. // CHECK:STDOUT: %other.patt: @I.WithSelf.F.%pattern_type (%pattern_type.fa0) = at_binding_pattern other, %other.param_patt [concrete]
  196. // CHECK:STDOUT: %return.param_patt: @I.WithSelf.F.%pattern_type (%pattern_type.fa0) = out_param_pattern [concrete]
  197. // CHECK:STDOUT: %return.patt: @I.WithSelf.F.%pattern_type (%pattern_type.fa0) = return_slot_pattern %return.param_patt, %.loc16_36.2 [concrete]
  198. // CHECK:STDOUT: } {
  199. // CHECK:STDOUT: %Self.ref.loc16_36: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self.ab9)]
  200. // CHECK:STDOUT: %Self.as_type.loc16_36: type = facet_access_type %Self.ref.loc16_36 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  201. // CHECK:STDOUT: %.loc16_36.2: type = converted %Self.ref.loc16_36, %Self.as_type.loc16_36 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  202. // CHECK:STDOUT: %.loc16_36.3: Core.Form = init_form %.loc16_36.2 [symbolic = %.loc16_36.1 (constants.%.e46)]
  203. // CHECK:STDOUT: %self.param: @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31) = value_param call_param0
  204. // CHECK:STDOUT: %.loc16_14.1: type = splice_block %.loc16_14.2 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)] {
  205. // CHECK:STDOUT: %Self.ref.loc16_14: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self.ab9)]
  206. // CHECK:STDOUT: %Self.as_type.loc16_14: type = facet_access_type %Self.ref.loc16_14 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  207. // CHECK:STDOUT: %.loc16_14.2: type = converted %Self.ref.loc16_14, %Self.as_type.loc16_14 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT: %self: @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31) = value_binding self, %self.param
  210. // CHECK:STDOUT: %other.param: @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31) = value_param call_param1
  211. // CHECK:STDOUT: %.loc16_27.1: type = splice_block %.loc16_27.2 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)] {
  212. // CHECK:STDOUT: %Self.ref.loc16_27: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self.ab9)]
  213. // CHECK:STDOUT: %Self.as_type.loc16_27: type = facet_access_type %Self.ref.loc16_27 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  214. // CHECK:STDOUT: %.loc16_27.2: type = converted %Self.ref.loc16_27, %Self.as_type.loc16_27 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  215. // CHECK:STDOUT: }
  216. // CHECK:STDOUT: %other: @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31) = value_binding other, %other.param
  217. // CHECK:STDOUT: %return.param: ref @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31) = out_param call_param2
  218. // CHECK:STDOUT: %return: ref @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31) = return_slot %return.param
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.WithSelf.F.decl [concrete = constants.%assoc0.18e]
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: !members:
  223. // CHECK:STDOUT: .Self = %Self
  224. // CHECK:STDOUT: .F = @I.WithSelf.%assoc0
  225. // CHECK:STDOUT: witness = (@I.WithSelf.%I.WithSelf.F.decl)
  226. // CHECK:STDOUT:
  227. // CHECK:STDOUT: !requires:
  228. // CHECK:STDOUT: }
  229. // CHECK:STDOUT:
  230. // CHECK:STDOUT: impl @i32.as.I.impl: %i32 as %I.ref {
  231. // CHECK:STDOUT: %i32.as.I.impl.F.decl: %i32.as.I.impl.F.type = fn_decl @i32.as.I.impl.F [concrete = constants.%i32.as.I.impl.F] {
  232. // CHECK:STDOUT: %self.param_patt: %pattern_type.7ce = value_param_pattern [concrete]
  233. // CHECK:STDOUT: %self.patt: %pattern_type.7ce = at_binding_pattern self, %self.param_patt [concrete]
  234. // CHECK:STDOUT: %other.param_patt: %pattern_type.7ce = value_param_pattern [concrete]
  235. // CHECK:STDOUT: %other.patt: %pattern_type.7ce = at_binding_pattern other, %other.param_patt [concrete]
  236. // CHECK:STDOUT: %return.param_patt: %pattern_type.7ce = out_param_pattern [concrete]
  237. // CHECK:STDOUT: %return.patt: %pattern_type.7ce = return_slot_pattern %return.param_patt, %i32.loc20_34 [concrete]
  238. // CHECK:STDOUT: } {
  239. // CHECK:STDOUT: %i32.loc20_34: type = type_literal constants.%i32 [concrete = constants.%i32]
  240. // CHECK:STDOUT: %.loc20: Core.Form = init_form %i32.loc20_34 [concrete = constants.%.ff5]
  241. // CHECK:STDOUT: %self.param: %i32 = value_param call_param0
  242. // CHECK:STDOUT: %i32.loc20_14: type = type_literal constants.%i32 [concrete = constants.%i32]
  243. // CHECK:STDOUT: %self: %i32 = value_binding self, %self.param
  244. // CHECK:STDOUT: %other.param: %i32 = value_param call_param1
  245. // CHECK:STDOUT: %i32.loc20_26: type = type_literal constants.%i32 [concrete = constants.%i32]
  246. // CHECK:STDOUT: %other: %i32 = value_binding other, %other.param
  247. // CHECK:STDOUT: %return.param: ref %i32 = out_param call_param2
  248. // CHECK:STDOUT: %return: ref %i32 = return_slot %return.param
  249. // CHECK:STDOUT: }
  250. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%i32.as.I.impl.F.decl), @i32.as.I.impl [concrete]
  251. // CHECK:STDOUT: %I.impl_witness: <witness> = impl_witness %I.impl_witness_table [concrete = constants.%I.impl_witness]
  252. // CHECK:STDOUT:
  253. // CHECK:STDOUT: !members:
  254. // CHECK:STDOUT: .F = %i32.as.I.impl.F.decl
  255. // CHECK:STDOUT: witness = %I.impl_witness
  256. // CHECK:STDOUT: }
  257. // CHECK:STDOUT:
  258. // CHECK:STDOUT: generic fn @I.WithSelf.F(@I.%Self: %I.type) {
  259. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self.ab9)]
  260. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type.d31)]
  261. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type (constants.%pattern_type.fa0)]
  262. // CHECK:STDOUT: %.loc16_36.1: Core.Form = init_form %Self.binding.as_type [symbolic = %.loc16_36.1 (constants.%.e46)]
  263. // CHECK:STDOUT:
  264. // CHECK:STDOUT: fn(%self.param: @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31), %other.param: @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31)) -> out %return.param: @I.WithSelf.F.%Self.binding.as_type (%Self.binding.as_type.d31);
  265. // CHECK:STDOUT: }
  266. // CHECK:STDOUT:
  267. // CHECK:STDOUT: fn @i32.as.I.impl.F(%self.param: %i32, %other.param: %i32) -> out %return.param: %i32 = "int.sadd";
  268. // CHECK:STDOUT:
  269. // CHECK:STDOUT: fn @__global_init() {
  270. // CHECK:STDOUT: !entry:
  271. // CHECK:STDOUT: %DefaultOrUnformed.facet: %DefaultOrUnformed.type = facet_value constants.%array_type, (constants.%DefaultOrUnformed.impl_witness.d11) [concrete = constants.%DefaultOrUnformed.facet]
  272. // CHECK:STDOUT: %.loc23_41.1: %DefaultOrUnformed.type = converted constants.%array_type, %DefaultOrUnformed.facet [concrete = constants.%DefaultOrUnformed.facet]
  273. // CHECK:STDOUT: %as_type: type = facet_access_type %.loc23_41.1 [concrete = constants.%array_type]
  274. // CHECK:STDOUT: %.loc23_41.2: type = converted %.loc23_41.1, %as_type [concrete = constants.%array_type]
  275. // CHECK:STDOUT: %T.as.DefaultOrUnformed.impl.Op.specific_fn: <specific function> = specific_function constants.%T.as.DefaultOrUnformed.impl.Op.9c0, @T.as.DefaultOrUnformed.impl.Op(constants.%array_type) [concrete = constants.%T.as.DefaultOrUnformed.impl.Op.specific_fn]
  276. // CHECK:STDOUT: %.loc23_1: ref %array_type = splice_block file.%arr.var [concrete = file.%arr.var] {}
  277. // CHECK:STDOUT: %T.as.DefaultOrUnformed.impl.Op.call: init %array_type to %.loc23_1 = call %T.as.DefaultOrUnformed.impl.Op.specific_fn()
  278. // CHECK:STDOUT: assign file.%arr.var, %T.as.DefaultOrUnformed.impl.Op.call
  279. // CHECK:STDOUT: return
  280. // CHECK:STDOUT: }
  281. // CHECK:STDOUT:
  282. // CHECK:STDOUT: specific @I.WithSelf(constants.%Self.ab9) {
  283. // CHECK:STDOUT: !definition:
  284. // CHECK:STDOUT: %Self => constants.%Self.ab9
  285. // CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.08c
  286. // CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.705
  287. // CHECK:STDOUT: }
  288. // CHECK:STDOUT:
  289. // CHECK:STDOUT: specific @I.WithSelf.F(constants.%Self.ab9) {
  290. // CHECK:STDOUT: %Self => constants.%Self.ab9
  291. // CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type.d31
  292. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.fa0
  293. // CHECK:STDOUT: %.loc16_36.1 => constants.%.e46
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: specific @I.WithSelf(constants.%I.facet) {
  297. // CHECK:STDOUT: !definition:
  298. // CHECK:STDOUT: %Self => constants.%I.facet
  299. // CHECK:STDOUT: %I.WithSelf.F.type => constants.%I.WithSelf.F.type.f37
  300. // CHECK:STDOUT: %I.WithSelf.F => constants.%I.WithSelf.F.b05
  301. // CHECK:STDOUT: }
  302. // CHECK:STDOUT:
  303. // CHECK:STDOUT: specific @I.WithSelf.F(constants.%I.facet) {
  304. // CHECK:STDOUT: %Self => constants.%I.facet
  305. // CHECK:STDOUT: %Self.binding.as_type => constants.%i32
  306. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.7ce
  307. // CHECK:STDOUT: %.loc16_36.1 => constants.%.ff5
  308. // CHECK:STDOUT: }
  309. // CHECK:STDOUT: