complete_in_conversion.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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/class/generic/complete_in_conversion.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/generic/complete_in_conversion.carbon
  14. // --- fail_derived_to_base.carbon
  15. fn Int(N: Core.IntLiteral()) -> type = "int.make_type_signed";
  16. base class B {}
  17. class A(N:! i32) {
  18. extend base: B;
  19. // CHECK:STDERR: fail_derived_to_base.carbon:[[@LINE+3]]:10: error: integer type width of 0 is not positive [IntWidthNotPositive]
  20. // CHECK:STDERR: var n: Int(N);
  21. // CHECK:STDERR: ^~~~~~
  22. var n: Int(N);
  23. }
  24. fn F(a: A(0)*) {
  25. // CHECK:STDERR: fail_derived_to_base.carbon:[[@LINE+4]]:15: note: in `A(0)` used here [ResolvingSpecificHere]
  26. // CHECK:STDERR: let b: B* = a;
  27. // CHECK:STDERR: ^
  28. // CHECK:STDERR:
  29. let b: B* = a;
  30. }
  31. // CHECK:STDOUT: --- fail_derived_to_base.carbon
  32. // CHECK:STDOUT:
  33. // CHECK:STDOUT: constants {
  34. // CHECK:STDOUT: %IntLiteral.type: type = fn_type @IntLiteral [concrete]
  35. // CHECK:STDOUT: %IntLiteral: %IntLiteral.type = struct_value () [concrete]
  36. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  37. // CHECK:STDOUT: %pattern_type.dc0: type = pattern_type Core.IntLiteral [concrete]
  38. // CHECK:STDOUT: %Int.type.913: type = fn_type @Int.loc2 [concrete]
  39. // CHECK:STDOUT: %Int.779: %Int.type.913 = struct_value () [concrete]
  40. // CHECK:STDOUT: %B: type = class_type @B [concrete]
  41. // CHECK:STDOUT: %Destroy.type: type = facet_type <@Destroy> [concrete]
  42. // CHECK:STDOUT: %pattern_type.f6d: type = pattern_type auto [concrete]
  43. // CHECK:STDOUT: %Destroy.impl_witness.40d: <witness> = impl_witness @B.%Destroy.impl_witness_table [concrete]
  44. // CHECK:STDOUT: %ptr.e79: type = ptr_type %B [concrete]
  45. // CHECK:STDOUT: %pattern_type.960: type = pattern_type %ptr.e79 [concrete]
  46. // CHECK:STDOUT: %B.as.Destroy.impl.Op.type: type = fn_type @B.as.Destroy.impl.Op [concrete]
  47. // CHECK:STDOUT: %B.as.Destroy.impl.Op: %B.as.Destroy.impl.Op.type = struct_value () [concrete]
  48. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  49. // CHECK:STDOUT: %complete_type.357: <witness> = complete_type_witness %empty_struct_type [concrete]
  50. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete]
  51. // CHECK:STDOUT: %Int.type.878: type = generic_class_type @Int.1 [concrete]
  52. // CHECK:STDOUT: %Int.generic: %Int.type.878 = struct_value () [concrete]
  53. // CHECK:STDOUT: %i32: type = class_type @Int.1, @Int.1(%int_32) [concrete]
  54. // CHECK:STDOUT: %N.51e: %i32 = bind_symbolic_name N, 0 [symbolic]
  55. // CHECK:STDOUT: %pattern_type.7ce: type = pattern_type %i32 [concrete]
  56. // CHECK:STDOUT: %A.type: type = generic_class_type @A [concrete]
  57. // CHECK:STDOUT: %A.generic: %A.type = struct_value () [concrete]
  58. // CHECK:STDOUT: %A.dd3: type = class_type @A, @A(%N.51e) [symbolic]
  59. // CHECK:STDOUT: %A.elem.500: type = unbound_element_type %A.dd3, %B [symbolic]
  60. // CHECK:STDOUT: %ImplicitAs.type.cc7: type = generic_interface_type @ImplicitAs [concrete]
  61. // CHECK:STDOUT: %ImplicitAs.generic: %ImplicitAs.type.cc7 = struct_value () [concrete]
  62. // CHECK:STDOUT: %ImplicitAs.type.2fd: type = facet_type <@ImplicitAs, @ImplicitAs(Core.IntLiteral)> [concrete]
  63. // CHECK:STDOUT: %ImplicitAs.Convert.type.71e: type = fn_type @ImplicitAs.Convert, @ImplicitAs(Core.IntLiteral) [concrete]
  64. // CHECK:STDOUT: %To: Core.IntLiteral = bind_symbolic_name To, 0 [symbolic]
  65. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0f9: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%To) [symbolic]
  66. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.f06: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0f9 = struct_value () [symbolic]
  67. // CHECK:STDOUT: %From: Core.IntLiteral = bind_symbolic_name From, 0 [symbolic]
  68. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.type.708: type = fn_type @Int.as.ImplicitAs.impl.Convert, @Int.as.ImplicitAs.impl(%From) [symbolic]
  69. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.c68: %Int.as.ImplicitAs.impl.Convert.type.708 = struct_value () [symbolic]
  70. // CHECK:STDOUT: %ImplicitAs.impl_witness.a11: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.1d9, @Int.as.ImplicitAs.impl(%int_32) [concrete]
  71. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.type.4ad: type = fn_type @Int.as.ImplicitAs.impl.Convert, @Int.as.ImplicitAs.impl(%int_32) [concrete]
  72. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.960: %Int.as.ImplicitAs.impl.Convert.type.4ad = struct_value () [concrete]
  73. // CHECK:STDOUT: %ImplicitAs.facet.f49: %ImplicitAs.type.2fd = facet_value %i32, (%ImplicitAs.impl_witness.a11) [concrete]
  74. // CHECK:STDOUT: %.0ea: type = fn_type_with_self_type %ImplicitAs.Convert.type.71e, %ImplicitAs.facet.f49 [concrete]
  75. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.bound.588: <bound method> = bound_method %N.51e, %Int.as.ImplicitAs.impl.Convert.960 [symbolic]
  76. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Int.as.ImplicitAs.impl.Convert.960, @Int.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  77. // CHECK:STDOUT: %bound_method.f9c: <bound method> = bound_method %N.51e, %Int.as.ImplicitAs.impl.Convert.specific_fn [symbolic]
  78. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.call: init Core.IntLiteral = call %bound_method.f9c(%N.51e) [symbolic]
  79. // CHECK:STDOUT: %iN.builtin.8fe: type = int_type signed, %Int.as.ImplicitAs.impl.Convert.call [symbolic]
  80. // CHECK:STDOUT: %require_complete.e34: <witness> = require_complete_type %iN.builtin.8fe [symbolic]
  81. // CHECK:STDOUT: %A.elem.07f: type = unbound_element_type %A.dd3, %iN.builtin.8fe [symbolic]
  82. // CHECK:STDOUT: %Destroy.impl_witness.3b2: <witness> = impl_witness @A.%Destroy.impl_witness_table, @A.as.Destroy.impl(%N.51e) [symbolic]
  83. // CHECK:STDOUT: %ptr.72a: type = ptr_type %A.dd3 [symbolic]
  84. // CHECK:STDOUT: %pattern_type.b2f: type = pattern_type %ptr.72a [symbolic]
  85. // CHECK:STDOUT: %A.as.Destroy.impl.Op.type: type = fn_type @A.as.Destroy.impl.Op, @A.as.Destroy.impl(%N.51e) [symbolic]
  86. // CHECK:STDOUT: %A.as.Destroy.impl.Op: %A.as.Destroy.impl.Op.type = struct_value () [symbolic]
  87. // CHECK:STDOUT: %struct_type.base.n: type = struct_type {.base: %B, .n: %iN.builtin.8fe} [symbolic]
  88. // CHECK:STDOUT: %complete_type.beb: <witness> = complete_type_witness %struct_type.base.n [symbolic]
  89. // CHECK:STDOUT: %int_0.5c6: Core.IntLiteral = int_value 0 [concrete]
  90. // CHECK:STDOUT: %ImplicitAs.type.205: type = facet_type <@ImplicitAs, @ImplicitAs(%i32)> [concrete]
  91. // CHECK:STDOUT: %ImplicitAs.Convert.type.1b6: type = fn_type @ImplicitAs.Convert, @ImplicitAs(%i32) [concrete]
  92. // CHECK:STDOUT: %ImplicitAs.impl_witness.c75: <witness> = impl_witness imports.%ImplicitAs.impl_witness_table.a2f, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  93. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.035: type = fn_type @Core.IntLiteral.as.ImplicitAs.impl.Convert, @Core.IntLiteral.as.ImplicitAs.impl(%int_32) [concrete]
  94. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.956: %Core.IntLiteral.as.ImplicitAs.impl.Convert.type.035 = struct_value () [concrete]
  95. // CHECK:STDOUT: %ImplicitAs.facet.921: %ImplicitAs.type.205 = facet_value Core.IntLiteral, (%ImplicitAs.impl_witness.c75) [concrete]
  96. // CHECK:STDOUT: %.9c3: type = fn_type_with_self_type %ImplicitAs.Convert.type.1b6, %ImplicitAs.facet.921 [concrete]
  97. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.956 [concrete]
  98. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn: <specific function> = specific_function %Core.IntLiteral.as.ImplicitAs.impl.Convert.956, @Core.IntLiteral.as.ImplicitAs.impl.Convert(%int_32) [concrete]
  99. // CHECK:STDOUT: %bound_method.b6e: <bound method> = bound_method %int_0.5c6, %Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  100. // CHECK:STDOUT: %int_0.6a9: %i32 = int_value 0 [concrete]
  101. // CHECK:STDOUT: %A.6fc: type = class_type @A, @A(%int_0.6a9) [concrete]
  102. // CHECK:STDOUT: %ptr.b65: type = ptr_type %A.6fc [concrete]
  103. // CHECK:STDOUT: %pattern_type.213: type = pattern_type %ptr.b65 [concrete]
  104. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  105. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  106. // CHECK:STDOUT: %A.elem.d81: type = unbound_element_type %A.6fc, %B [concrete]
  107. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.bound.0fd: <bound method> = bound_method %int_0.6a9, %Int.as.ImplicitAs.impl.Convert.960 [concrete]
  108. // CHECK:STDOUT: %bound_method.4b5: <bound method> = bound_method %int_0.6a9, %Int.as.ImplicitAs.impl.Convert.specific_fn [concrete]
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT:
  111. // CHECK:STDOUT: imports {
  112. // CHECK:STDOUT: %Core: <namespace> = namespace file.%Core.import, [concrete] {
  113. // CHECK:STDOUT: .IntLiteral = %Core.IntLiteral
  114. // CHECK:STDOUT: .Destroy = %Core.Destroy
  115. // CHECK:STDOUT: .Int = %Core.Int
  116. // CHECK:STDOUT: .ImplicitAs = %Core.ImplicitAs
  117. // CHECK:STDOUT: import Core//prelude
  118. // CHECK:STDOUT: import Core//prelude/...
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT: %Core.IntLiteral: %IntLiteral.type = import_ref Core//prelude/parts/int_literal, IntLiteral, loaded [concrete = constants.%IntLiteral]
  121. // CHECK:STDOUT: %Core.Destroy: type = import_ref Core//prelude/parts/destroy, Destroy, loaded [concrete = constants.%Destroy.type]
  122. // CHECK:STDOUT: %Core.Int: %Int.type.878 = import_ref Core//prelude/parts/int, Int, loaded [concrete = constants.%Int.generic]
  123. // CHECK:STDOUT: %Core.ImplicitAs: %ImplicitAs.type.cc7 = import_ref Core//prelude/parts/as, ImplicitAs, loaded [concrete = constants.%ImplicitAs.generic]
  124. // CHECK:STDOUT: %Core.import_ref.a5b: @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert.type (%Core.IntLiteral.as.ImplicitAs.impl.Convert.type.0f9) = import_ref Core//prelude/parts/int, loc16_39, loaded [symbolic = @Core.IntLiteral.as.ImplicitAs.impl.%Core.IntLiteral.as.ImplicitAs.impl.Convert (constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.f06)]
  125. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.a2f = impl_witness_table (%Core.import_ref.a5b), @Core.IntLiteral.as.ImplicitAs.impl [concrete]
  126. // CHECK:STDOUT: %Core.import_ref.85c: @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert.type (%Int.as.ImplicitAs.impl.Convert.type.708) = import_ref Core//prelude/parts/int, loc20_44, loaded [symbolic = @Int.as.ImplicitAs.impl.%Int.as.ImplicitAs.impl.Convert (constants.%Int.as.ImplicitAs.impl.Convert.c68)]
  127. // CHECK:STDOUT: %ImplicitAs.impl_witness_table.1d9 = impl_witness_table (%Core.import_ref.85c), @Int.as.ImplicitAs.impl [concrete]
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT:
  130. // CHECK:STDOUT: file {
  131. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  132. // CHECK:STDOUT: .Core = imports.%Core
  133. // CHECK:STDOUT: .Int = %Int.decl
  134. // CHECK:STDOUT: .B = %B.decl
  135. // CHECK:STDOUT: .A = %A.decl
  136. // CHECK:STDOUT: .F = %F.decl
  137. // CHECK:STDOUT: }
  138. // CHECK:STDOUT: %Core.import = import Core
  139. // CHECK:STDOUT: %Int.decl: %Int.type.913 = fn_decl @Int.loc2 [concrete = constants.%Int.779] {
  140. // CHECK:STDOUT: %N.patt: %pattern_type.dc0 = binding_pattern N [concrete]
  141. // CHECK:STDOUT: %N.param_patt: %pattern_type.dc0 = value_param_pattern %N.patt, call_param0 [concrete]
  142. // CHECK:STDOUT: %return.patt: %pattern_type.98f = return_slot_pattern [concrete]
  143. // CHECK:STDOUT: %return.param_patt: %pattern_type.98f = out_param_pattern %return.patt, call_param1 [concrete]
  144. // CHECK:STDOUT: } {
  145. // CHECK:STDOUT: %N.param: Core.IntLiteral = value_param call_param0
  146. // CHECK:STDOUT: %.loc2_27.1: type = splice_block %.loc2_27.3 [concrete = Core.IntLiteral] {
  147. // CHECK:STDOUT: %Core.ref: <namespace> = name_ref Core, imports.%Core [concrete = imports.%Core]
  148. // CHECK:STDOUT: %IntLiteral.ref: %IntLiteral.type = name_ref IntLiteral, imports.%Core.IntLiteral [concrete = constants.%IntLiteral]
  149. // CHECK:STDOUT: %IntLiteral.call: init type = call %IntLiteral.ref() [concrete = Core.IntLiteral]
  150. // CHECK:STDOUT: %.loc2_27.2: type = value_of_initializer %IntLiteral.call [concrete = Core.IntLiteral]
  151. // CHECK:STDOUT: %.loc2_27.3: type = converted %IntLiteral.call, %.loc2_27.2 [concrete = Core.IntLiteral]
  152. // CHECK:STDOUT: }
  153. // CHECK:STDOUT: %N: Core.IntLiteral = bind_name N, %N.param
  154. // CHECK:STDOUT: %return.param: ref type = out_param call_param1
  155. // CHECK:STDOUT: %return: ref type = return_slot %return.param
  156. // CHECK:STDOUT: }
  157. // CHECK:STDOUT: %B.decl: type = class_decl @B [concrete = constants.%B] {} {}
  158. // CHECK:STDOUT: %A.decl: %A.type = class_decl @A [concrete = constants.%A.generic] {
  159. // CHECK:STDOUT: %N.patt: %pattern_type.7ce = symbolic_binding_pattern N, 0 [concrete]
  160. // CHECK:STDOUT: } {
  161. // CHECK:STDOUT: %.loc6: type = splice_block %i32 [concrete = constants.%i32] {
  162. // CHECK:STDOUT: %int_32: Core.IntLiteral = int_value 32 [concrete = constants.%int_32]
  163. // CHECK:STDOUT: %i32: type = class_type @Int.1, @Int.1(constants.%int_32) [concrete = constants.%i32]
  164. // CHECK:STDOUT: }
  165. // CHECK:STDOUT: %N.loc6_9.2: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc6_9.1 (constants.%N.51e)]
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  168. // CHECK:STDOUT: %a.patt: %pattern_type.213 = binding_pattern a [concrete]
  169. // CHECK:STDOUT: %a.param_patt: %pattern_type.213 = value_param_pattern %a.patt, call_param0 [concrete]
  170. // CHECK:STDOUT: } {
  171. // CHECK:STDOUT: %a.param: %ptr.b65 = value_param call_param0
  172. // CHECK:STDOUT: %.loc15_13: type = splice_block %ptr.loc15 [concrete = constants.%ptr.b65] {
  173. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [concrete = constants.%A.generic]
  174. // CHECK:STDOUT: %int_0: Core.IntLiteral = int_value 0 [concrete = constants.%int_0.5c6]
  175. // CHECK:STDOUT: %impl.elem0: %.9c3 = impl_witness_access constants.%ImplicitAs.impl_witness.c75, element0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.956]
  176. // CHECK:STDOUT: %bound_method.loc15_12.1: <bound method> = bound_method %int_0, %impl.elem0 [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.bound]
  177. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Core.IntLiteral.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Core.IntLiteral.as.ImplicitAs.impl.Convert.specific_fn]
  178. // CHECK:STDOUT: %bound_method.loc15_12.2: <bound method> = bound_method %int_0, %specific_fn [concrete = constants.%bound_method.b6e]
  179. // CHECK:STDOUT: %Core.IntLiteral.as.ImplicitAs.impl.Convert.call: init %i32 = call %bound_method.loc15_12.2(%int_0) [concrete = constants.%int_0.6a9]
  180. // CHECK:STDOUT: %.loc15_12.1: %i32 = value_of_initializer %Core.IntLiteral.as.ImplicitAs.impl.Convert.call [concrete = constants.%int_0.6a9]
  181. // CHECK:STDOUT: %.loc15_12.2: %i32 = converted %int_0, %.loc15_12.1 [concrete = constants.%int_0.6a9]
  182. // CHECK:STDOUT: %A: type = class_type @A, @A(constants.%int_0.6a9) [concrete = constants.%A.6fc]
  183. // CHECK:STDOUT: %ptr.loc15: type = ptr_type %A [concrete = constants.%ptr.b65]
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT: %a: %ptr.b65 = bind_name a, %a.param
  186. // CHECK:STDOUT: }
  187. // CHECK:STDOUT: }
  188. // CHECK:STDOUT:
  189. // CHECK:STDOUT: impl @B.as.Destroy.impl: @B.%Self.ref as constants.%Destroy.type {
  190. // CHECK:STDOUT: %B.as.Destroy.impl.Op.decl: %B.as.Destroy.impl.Op.type = fn_decl @B.as.Destroy.impl.Op [concrete = constants.%B.as.Destroy.impl.Op] {
  191. // CHECK:STDOUT: %self.patt: %pattern_type.960 = binding_pattern self [concrete]
  192. // CHECK:STDOUT: %self.param_patt: %pattern_type.960 = value_param_pattern %self.patt, call_param0 [concrete]
  193. // CHECK:STDOUT: %.loc4: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  194. // CHECK:STDOUT: } {
  195. // CHECK:STDOUT: %self.param: %ptr.e79 = value_param call_param0
  196. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%B [concrete = constants.%B]
  197. // CHECK:STDOUT: %self: %ptr.e79 = bind_name self, %self.param
  198. // CHECK:STDOUT: }
  199. // CHECK:STDOUT:
  200. // CHECK:STDOUT: !members:
  201. // CHECK:STDOUT: .Op = %B.as.Destroy.impl.Op.decl
  202. // CHECK:STDOUT: witness = @B.%Destroy.impl_witness
  203. // CHECK:STDOUT: }
  204. // CHECK:STDOUT:
  205. // CHECK:STDOUT: generic impl @A.as.Destroy.impl(@A.%N.loc6_9.2: %i32) {
  206. // CHECK:STDOUT: %N: %i32 = bind_symbolic_name N, 0 [symbolic = %N (constants.%N.51e)]
  207. // CHECK:STDOUT: %A: type = class_type @A, @A(%N) [symbolic = %A (constants.%A.dd3)]
  208. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness @A.%Destroy.impl_witness_table, @A.as.Destroy.impl(%N) [symbolic = %Destroy.impl_witness (constants.%Destroy.impl_witness.3b2)]
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: !definition:
  211. // CHECK:STDOUT: %A.as.Destroy.impl.Op.type: type = fn_type @A.as.Destroy.impl.Op, @A.as.Destroy.impl(%N) [symbolic = %A.as.Destroy.impl.Op.type (constants.%A.as.Destroy.impl.Op.type)]
  212. // CHECK:STDOUT: %A.as.Destroy.impl.Op: @A.as.Destroy.impl.%A.as.Destroy.impl.Op.type (%A.as.Destroy.impl.Op.type) = struct_value () [symbolic = %A.as.Destroy.impl.Op (constants.%A.as.Destroy.impl.Op)]
  213. // CHECK:STDOUT:
  214. // CHECK:STDOUT: impl: @A.%Self.ref as constants.%Destroy.type {
  215. // CHECK:STDOUT: %A.as.Destroy.impl.Op.decl: @A.as.Destroy.impl.%A.as.Destroy.impl.Op.type (%A.as.Destroy.impl.Op.type) = fn_decl @A.as.Destroy.impl.Op [symbolic = @A.as.Destroy.impl.%A.as.Destroy.impl.Op (constants.%A.as.Destroy.impl.Op)] {
  216. // CHECK:STDOUT: %self.patt: @A.as.Destroy.impl.Op.%pattern_type (%pattern_type.b2f) = binding_pattern self [concrete]
  217. // CHECK:STDOUT: %self.param_patt: @A.as.Destroy.impl.Op.%pattern_type (%pattern_type.b2f) = value_param_pattern %self.patt, call_param0 [concrete]
  218. // CHECK:STDOUT: %.loc6_18.1: %pattern_type.f6d = addr_pattern %self.param_patt [concrete]
  219. // CHECK:STDOUT: } {
  220. // CHECK:STDOUT: %self.param: @A.as.Destroy.impl.Op.%ptr (%ptr.72a) = value_param call_param0
  221. // CHECK:STDOUT: %.loc6_18.2: type = splice_block %Self.ref [symbolic = %A (constants.%A.dd3)] {
  222. // CHECK:STDOUT: %.loc6_18.3: type = specific_constant constants.%A.dd3, @A(constants.%N.51e) [symbolic = %A (constants.%A.dd3)]
  223. // CHECK:STDOUT: %Self.ref: type = name_ref Self, %.loc6_18.3 [symbolic = %A (constants.%A.dd3)]
  224. // CHECK:STDOUT: }
  225. // CHECK:STDOUT: %self: @A.as.Destroy.impl.Op.%ptr (%ptr.72a) = bind_name self, %self.param
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: !members:
  229. // CHECK:STDOUT: .Op = %A.as.Destroy.impl.Op.decl
  230. // CHECK:STDOUT: witness = @A.%Destroy.impl_witness
  231. // CHECK:STDOUT: }
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: class @B {
  235. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%B [concrete = constants.%B]
  236. // CHECK:STDOUT: impl_decl @B.as.Destroy.impl [concrete] {} {}
  237. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@B.as.Destroy.impl.%B.as.Destroy.impl.Op.decl), @B.as.Destroy.impl [concrete]
  238. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table [concrete = constants.%Destroy.impl_witness.40d]
  239. // CHECK:STDOUT: %complete_type: <witness> = complete_type_witness constants.%empty_struct_type [concrete = constants.%complete_type.357]
  240. // CHECK:STDOUT: complete_type_witness = %complete_type
  241. // CHECK:STDOUT:
  242. // CHECK:STDOUT: !members:
  243. // CHECK:STDOUT: .Self = constants.%B
  244. // CHECK:STDOUT: .Int = <poisoned>
  245. // CHECK:STDOUT: .N = <poisoned>
  246. // CHECK:STDOUT: }
  247. // CHECK:STDOUT:
  248. // CHECK:STDOUT: generic class @A(%N.loc6_9.2: %i32) {
  249. // CHECK:STDOUT: %N.loc6_9.1: %i32 = bind_symbolic_name N, 0 [symbolic = %N.loc6_9.1 (constants.%N.51e)]
  250. // CHECK:STDOUT:
  251. // CHECK:STDOUT: !definition:
  252. // CHECK:STDOUT: %A: type = class_type @A, @A(%N.loc6_9.1) [symbolic = %A (constants.%A.dd3)]
  253. // CHECK:STDOUT: %A.elem.loc7: type = unbound_element_type %A, constants.%B [symbolic = %A.elem.loc7 (constants.%A.elem.500)]
  254. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.bound: <bound method> = bound_method %N.loc6_9.1, constants.%Int.as.ImplicitAs.impl.Convert.960 [symbolic = %Int.as.ImplicitAs.impl.Convert.bound (constants.%Int.as.ImplicitAs.impl.Convert.bound.588)]
  255. // CHECK:STDOUT: %bound_method.loc12_14.3: <bound method> = bound_method %N.loc6_9.1, constants.%Int.as.ImplicitAs.impl.Convert.specific_fn [symbolic = %bound_method.loc12_14.3 (constants.%bound_method.f9c)]
  256. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.call.loc12_14.2: init Core.IntLiteral = call %bound_method.loc12_14.3(%N.loc6_9.1) [symbolic = %Int.as.ImplicitAs.impl.Convert.call.loc12_14.2 (constants.%Int.as.ImplicitAs.impl.Convert.call)]
  257. // CHECK:STDOUT: %iN.builtin: type = int_type signed, %Int.as.ImplicitAs.impl.Convert.call.loc12_14.2 [symbolic = %iN.builtin (constants.%iN.builtin.8fe)]
  258. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %iN.builtin [symbolic = %require_complete (constants.%require_complete.e34)]
  259. // CHECK:STDOUT: %A.elem.loc12: type = unbound_element_type %A, %iN.builtin [symbolic = %A.elem.loc12 (constants.%A.elem.07f)]
  260. // CHECK:STDOUT: %struct_type.base.n: type = struct_type {.base: %B, .n: @A.%iN.builtin (%iN.builtin.8fe)} [symbolic = %struct_type.base.n (constants.%struct_type.base.n)]
  261. // CHECK:STDOUT: %complete_type.loc13_1.2: <witness> = complete_type_witness %struct_type.base.n [symbolic = %complete_type.loc13_1.2 (constants.%complete_type.beb)]
  262. // CHECK:STDOUT:
  263. // CHECK:STDOUT: class {
  264. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  265. // CHECK:STDOUT: %.loc7: @A.%A.elem.loc7 (%A.elem.500) = base_decl %B.ref, element0 [concrete]
  266. // CHECK:STDOUT: %Int.ref: %Int.type.913 = name_ref Int, file.%Int.decl [concrete = constants.%Int.779]
  267. // CHECK:STDOUT: %N.ref: %i32 = name_ref N, %N.loc6_9.2 [symbolic = %N.loc6_9.1 (constants.%N.51e)]
  268. // CHECK:STDOUT: %impl.elem0: %.0ea = impl_witness_access constants.%ImplicitAs.impl_witness.a11, element0 [concrete = constants.%Int.as.ImplicitAs.impl.Convert.960]
  269. // CHECK:STDOUT: %bound_method.loc12_14.1: <bound method> = bound_method %N.ref, %impl.elem0 [symbolic = %Int.as.ImplicitAs.impl.Convert.bound (constants.%Int.as.ImplicitAs.impl.Convert.bound.588)]
  270. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @Int.as.ImplicitAs.impl.Convert(constants.%int_32) [concrete = constants.%Int.as.ImplicitAs.impl.Convert.specific_fn]
  271. // CHECK:STDOUT: %bound_method.loc12_14.2: <bound method> = bound_method %N.ref, %specific_fn [symbolic = %bound_method.loc12_14.3 (constants.%bound_method.f9c)]
  272. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.call.loc12_14.1: init Core.IntLiteral = call %bound_method.loc12_14.2(%N.ref) [symbolic = %Int.as.ImplicitAs.impl.Convert.call.loc12_14.2 (constants.%Int.as.ImplicitAs.impl.Convert.call)]
  273. // CHECK:STDOUT: %.loc12_14.1: Core.IntLiteral = value_of_initializer %Int.as.ImplicitAs.impl.Convert.call.loc12_14.1 [symbolic = %Int.as.ImplicitAs.impl.Convert.call.loc12_14.2 (constants.%Int.as.ImplicitAs.impl.Convert.call)]
  274. // CHECK:STDOUT: %.loc12_14.2: Core.IntLiteral = converted %N.ref, %.loc12_14.1 [symbolic = %Int.as.ImplicitAs.impl.Convert.call.loc12_14.2 (constants.%Int.as.ImplicitAs.impl.Convert.call)]
  275. // CHECK:STDOUT: %Int.call: init type = call %Int.ref(%.loc12_14.2) [symbolic = %iN.builtin (constants.%iN.builtin.8fe)]
  276. // CHECK:STDOUT: %.loc12_15.1: type = value_of_initializer %Int.call [symbolic = %iN.builtin (constants.%iN.builtin.8fe)]
  277. // CHECK:STDOUT: %.loc12_15.2: type = converted %Int.call, %.loc12_15.1 [symbolic = %iN.builtin (constants.%iN.builtin.8fe)]
  278. // CHECK:STDOUT: %.loc12_8: @A.%A.elem.loc12 (%A.elem.07f) = field_decl n, element1 [concrete]
  279. // CHECK:STDOUT: %Self.ref: type = name_ref Self, constants.%A.dd3 [symbolic = @A.as.Destroy.impl.%A (constants.%A.dd3)]
  280. // CHECK:STDOUT: impl_decl @A.as.Destroy.impl [concrete] {} {}
  281. // CHECK:STDOUT: %Destroy.impl_witness_table = impl_witness_table (@A.as.Destroy.impl.%A.as.Destroy.impl.Op.decl), @A.as.Destroy.impl [concrete]
  282. // CHECK:STDOUT: %Destroy.impl_witness: <witness> = impl_witness %Destroy.impl_witness_table, @A.as.Destroy.impl(constants.%N.51e) [symbolic = @A.as.Destroy.impl.%Destroy.impl_witness (constants.%Destroy.impl_witness.3b2)]
  283. // CHECK:STDOUT: %complete_type.loc13_1.1: <witness> = complete_type_witness constants.%struct_type.base.n [symbolic = %complete_type.loc13_1.2 (constants.%complete_type.beb)]
  284. // CHECK:STDOUT: complete_type_witness = %complete_type.loc13_1.1
  285. // CHECK:STDOUT:
  286. // CHECK:STDOUT: !members:
  287. // CHECK:STDOUT: .Self = constants.%A.dd3
  288. // CHECK:STDOUT: .B = <poisoned>
  289. // CHECK:STDOUT: .base = %.loc7
  290. // CHECK:STDOUT: .Int = <poisoned>
  291. // CHECK:STDOUT: .N = <poisoned>
  292. // CHECK:STDOUT: .n = %.loc12_8
  293. // CHECK:STDOUT: extend %B.ref
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT: }
  296. // CHECK:STDOUT:
  297. // CHECK:STDOUT: fn @Int.loc2(%N.param: Core.IntLiteral) -> type = "int.make_type_signed";
  298. // CHECK:STDOUT:
  299. // CHECK:STDOUT: fn @B.as.Destroy.impl.Op(%self.param: %ptr.e79) = "no_op";
  300. // CHECK:STDOUT:
  301. // CHECK:STDOUT: generic fn @A.as.Destroy.impl.Op(@A.%N.loc6_9.2: %i32) {
  302. // CHECK:STDOUT: %N: %i32 = bind_symbolic_name N, 0 [symbolic = %N (constants.%N.51e)]
  303. // CHECK:STDOUT: %A: type = class_type @A, @A(%N) [symbolic = %A (constants.%A.dd3)]
  304. // CHECK:STDOUT: %ptr: type = ptr_type %A [symbolic = %ptr (constants.%ptr.72a)]
  305. // CHECK:STDOUT: %pattern_type: type = pattern_type %ptr [symbolic = %pattern_type (constants.%pattern_type.b2f)]
  306. // CHECK:STDOUT:
  307. // CHECK:STDOUT: !definition:
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: fn(%self.param: @A.as.Destroy.impl.Op.%ptr (%ptr.72a)) = "no_op";
  310. // CHECK:STDOUT: }
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: fn @F(%a.param: %ptr.b65) {
  313. // CHECK:STDOUT: !entry:
  314. // CHECK:STDOUT: name_binding_decl {
  315. // CHECK:STDOUT: %b.patt: %pattern_type.960 = binding_pattern b [concrete]
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT: %a.ref: %ptr.b65 = name_ref a, %a
  318. // CHECK:STDOUT: %.loc20_11: type = splice_block %ptr.loc20 [concrete = constants.%ptr.e79] {
  319. // CHECK:STDOUT: %B.ref: type = name_ref B, file.%B.decl [concrete = constants.%B]
  320. // CHECK:STDOUT: %ptr.loc20: type = ptr_type %B.ref [concrete = constants.%ptr.e79]
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT: %.loc20_15.1: ref %A.6fc = deref %a.ref
  323. // CHECK:STDOUT: %.loc20_15.2: ref %B = class_element_access %.loc20_15.1, element0
  324. // CHECK:STDOUT: %addr: %ptr.e79 = addr_of %.loc20_15.2
  325. // CHECK:STDOUT: %.loc20_15.3: %ptr.e79 = converted %a.ref, %addr
  326. // CHECK:STDOUT: %b: %ptr.e79 = bind_name b, %.loc20_15.3
  327. // CHECK:STDOUT: return
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: specific @A(constants.%N.51e) {
  331. // CHECK:STDOUT: %N.loc6_9.1 => constants.%N.51e
  332. // CHECK:STDOUT: }
  333. // CHECK:STDOUT:
  334. // CHECK:STDOUT: specific @A.as.Destroy.impl(constants.%N.51e) {
  335. // CHECK:STDOUT: %N => constants.%N.51e
  336. // CHECK:STDOUT: %A => constants.%A.dd3
  337. // CHECK:STDOUT: %Destroy.impl_witness => constants.%Destroy.impl_witness.3b2
  338. // CHECK:STDOUT: }
  339. // CHECK:STDOUT:
  340. // CHECK:STDOUT: specific @A.as.Destroy.impl.Op(constants.%N.51e) {
  341. // CHECK:STDOUT: %N => constants.%N.51e
  342. // CHECK:STDOUT: %A => constants.%A.dd3
  343. // CHECK:STDOUT: %ptr => constants.%ptr.72a
  344. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.b2f
  345. // CHECK:STDOUT: }
  346. // CHECK:STDOUT:
  347. // CHECK:STDOUT: specific @A(constants.%int_0.6a9) {
  348. // CHECK:STDOUT: %N.loc6_9.1 => constants.%int_0.6a9
  349. // CHECK:STDOUT:
  350. // CHECK:STDOUT: !definition:
  351. // CHECK:STDOUT: %A => constants.%A.6fc
  352. // CHECK:STDOUT: %A.elem.loc7 => constants.%A.elem.d81
  353. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.bound => constants.%Int.as.ImplicitAs.impl.Convert.bound.0fd
  354. // CHECK:STDOUT: %bound_method.loc12_14.3 => constants.%bound_method.4b5
  355. // CHECK:STDOUT: %Int.as.ImplicitAs.impl.Convert.call.loc12_14.2 => constants.%int_0.5c6
  356. // CHECK:STDOUT: %iN.builtin => <error>
  357. // CHECK:STDOUT: %require_complete => <error>
  358. // CHECK:STDOUT: %A.elem.loc12 => <error>
  359. // CHECK:STDOUT: %struct_type.base.n => <error>
  360. // CHECK:STDOUT: %complete_type.loc13_1.2 => <error>
  361. // CHECK:STDOUT: }
  362. // CHECK:STDOUT: