impl_forall.carbon 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // INCLUDE-FILE: toolchain/testing/testdata/min_prelude/convert.carbon
  6. //
  7. // AUTOUPDATE
  8. // TIP: To test this file alone, run:
  9. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/impl/lookup/impl_forall.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/lookup/impl_forall.carbon
  12. // --- impl_forall.carbon
  13. library "[[@TEST_NAME]]";
  14. class A(T:! type) {
  15. var n: T;
  16. }
  17. interface I(U:! type) {
  18. fn F[ref self: Self]() -> U*;
  19. }
  20. //@dump-sem-ir-begin
  21. impl forall [V:! type] A(V) as I(V) {
  22. fn F[ref self: Self]() -> V* {
  23. return &self.n;
  24. }
  25. }
  26. //@dump-sem-ir-end
  27. fn TestGeneric[W:! type](a: A(W)*) -> W* {
  28. //@dump-sem-ir-begin
  29. return a->(I(W).F)();
  30. //@dump-sem-ir-end
  31. }
  32. fn TestSpecific(a: A({})*) -> {}* {
  33. //@dump-sem-ir-begin
  34. return a->(I({}).F)();
  35. //@dump-sem-ir-end
  36. }
  37. // CHECK:STDOUT: --- impl_forall.carbon
  38. // CHECK:STDOUT:
  39. // CHECK:STDOUT: constants {
  40. // CHECK:STDOUT: %pattern_type.98f: type = pattern_type type [concrete]
  41. // CHECK:STDOUT: %T.67d: type = symbolic_binding T, 0 [symbolic]
  42. // CHECK:STDOUT: %A.type: type = generic_class_type @A [concrete]
  43. // CHECK:STDOUT: %A.generic: %A.type = struct_value () [concrete]
  44. // CHECK:STDOUT: %U.67d: type = symbolic_binding U, 0 [symbolic]
  45. // CHECK:STDOUT: %I.type.609: type = generic_interface_type @I [concrete]
  46. // CHECK:STDOUT: %I.generic: %I.type.609 = struct_value () [concrete]
  47. // CHECK:STDOUT: %I.type.1ab3e4.1: type = facet_type <@I, @I(%U.67d)> [symbolic]
  48. // CHECK:STDOUT: %Self.fdb544.1: %I.type.1ab3e4.1 = symbolic_binding Self, 1 [symbolic]
  49. // CHECK:STDOUT: %V.67d: type = symbolic_binding V, 0 [symbolic]
  50. // CHECK:STDOUT: %A.95c0c7.2: type = class_type @A, @A(%V.67d) [symbolic]
  51. // CHECK:STDOUT: %I.type.1ab3e4.2: type = facet_type <@I, @I(%V.67d)> [symbolic]
  52. // CHECK:STDOUT: %I.impl_witness.f3f3bd.1: <witness> = impl_witness @A.as.I.impl.%I.impl_witness_table, @A.as.I.impl(%V.67d) [symbolic]
  53. // CHECK:STDOUT: %require_complete.e360af.1: <witness> = require_complete_type %I.type.1ab3e4.2 [symbolic]
  54. // CHECK:STDOUT: %pattern_type.2c404c.1: type = pattern_type %A.95c0c7.2 [symbolic]
  55. // CHECK:STDOUT: %ptr.e8f8f9.2: type = ptr_type %V.67d [symbolic]
  56. // CHECK:STDOUT: %.cb6cb9.2: Core.Form = init_form %ptr.e8f8f9.2 [symbolic]
  57. // CHECK:STDOUT: %pattern_type.4f4b84.2: type = pattern_type %ptr.e8f8f9.2 [symbolic]
  58. // CHECK:STDOUT: %A.as.I.impl.F.type.58747b.1: type = fn_type @A.as.I.impl.F, @A.as.I.impl(%V.67d) [symbolic]
  59. // CHECK:STDOUT: %A.as.I.impl.F.afeb91.1: %A.as.I.impl.F.type.58747b.1 = struct_value () [symbolic]
  60. // CHECK:STDOUT: %A.elem.8a20fa.2: type = unbound_element_type %A.95c0c7.2, %V.67d [symbolic]
  61. // CHECK:STDOUT: %require_complete.fd6: <witness> = require_complete_type %A.95c0c7.2 [symbolic]
  62. // CHECK:STDOUT: %require_complete.ef162c.1: <witness> = require_complete_type %ptr.e8f8f9.2 [symbolic]
  63. // CHECK:STDOUT: %Copy.type: type = facet_type <@Copy> [concrete]
  64. // CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.2d4455.1: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%T.67d) [symbolic]
  65. // CHECK:STDOUT: %ptr.as.Copy.impl.Op.74e93b.1: %ptr.as.Copy.impl.Op.type.2d4455.1 = struct_value () [symbolic]
  66. // CHECK:STDOUT: %Copy.lookup_impl_witness.2e6: <witness> = lookup_impl_witness %ptr.e8f8f9.2, @Copy [symbolic]
  67. // CHECK:STDOUT: %.2f2: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%V.67d) [symbolic]
  68. // CHECK:STDOUT: %Copy.facet.c25: %Copy.type = facet_value %ptr.e8f8f9.2, (%Copy.lookup_impl_witness.2e6) [symbolic]
  69. // CHECK:STDOUT: %Copy.WithSelf.Op.type.d82: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.c25) [symbolic]
  70. // CHECK:STDOUT: %.299: type = fn_type_with_self_type %Copy.WithSelf.Op.type.d82, %Copy.facet.c25 [symbolic]
  71. // CHECK:STDOUT: %impl.elem0.1c7: %.299 = impl_witness_access %Copy.lookup_impl_witness.2e6, element0 [symbolic]
  72. // CHECK:STDOUT: %specific_impl_fn.366: <specific function> = specific_impl_function %impl.elem0.1c7, @Copy.WithSelf.Op(%Copy.facet.c25) [symbolic]
  73. // CHECK:STDOUT: %W: type = symbolic_binding W, 0 [symbolic]
  74. // CHECK:STDOUT: %A.95c0c7.3: type = class_type @A, @A(%W) [symbolic]
  75. // CHECK:STDOUT: %ptr.5da: type = ptr_type %A.95c0c7.3 [symbolic]
  76. // CHECK:STDOUT: %pattern_type.605: type = pattern_type %ptr.5da [symbolic]
  77. // CHECK:STDOUT: %ptr.e8f8f9.4: type = ptr_type %W [symbolic]
  78. // CHECK:STDOUT: %.cb6cb9.4: Core.Form = init_form %ptr.e8f8f9.4 [symbolic]
  79. // CHECK:STDOUT: %pattern_type.4f4b84.4: type = pattern_type %ptr.e8f8f9.4 [symbolic]
  80. // CHECK:STDOUT: %I.type.1ab3e4.3: type = facet_type <@I, @I(%W)> [symbolic]
  81. // CHECK:STDOUT: %I.assoc_type.76c031.3: type = assoc_entity_type @I, @I(%W) [symbolic]
  82. // CHECK:STDOUT: %assoc0.203667.3: %I.assoc_type.76c031.3 = assoc_entity element0, @I.WithSelf.%I.WithSelf.F.decl [symbolic]
  83. // CHECK:STDOUT: %require_complete.e360af.2: <witness> = require_complete_type %I.type.1ab3e4.3 [symbolic]
  84. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %A.95c0c7.3, @I, @I(%W) [symbolic]
  85. // CHECK:STDOUT: %I.impl_witness.f3f3bd.2: <witness> = impl_witness @A.as.I.impl.%I.impl_witness_table, @A.as.I.impl(%W) [symbolic]
  86. // CHECK:STDOUT: %A.as.I.impl.F.type.58747b.2: type = fn_type @A.as.I.impl.F, @A.as.I.impl(%W) [symbolic]
  87. // CHECK:STDOUT: %A.as.I.impl.F.afeb91.2: %A.as.I.impl.F.type.58747b.2 = struct_value () [symbolic]
  88. // CHECK:STDOUT: %.0fe: require_specific_def_type = require_specific_def @A.as.I.impl(%W) [symbolic]
  89. // CHECK:STDOUT: %I.facet.558: %I.type.1ab3e4.3 = facet_value %A.95c0c7.3, (%I.lookup_impl_witness) [symbolic]
  90. // CHECK:STDOUT: %I.WithSelf.F.type.912: type = fn_type @I.WithSelf.F, @I.WithSelf(%W, %I.facet.558) [symbolic]
  91. // CHECK:STDOUT: %.695: type = fn_type_with_self_type %I.WithSelf.F.type.912, %I.facet.558 [symbolic]
  92. // CHECK:STDOUT: %impl.elem0.976: %.695 = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  93. // CHECK:STDOUT: %specific_impl_fn.3c2: <specific function> = specific_impl_function %impl.elem0.976, @I.WithSelf.F(%W, %I.facet.558) [symbolic]
  94. // CHECK:STDOUT: %empty_struct_type: type = struct_type {} [concrete]
  95. // CHECK:STDOUT: %empty_struct: %empty_struct_type = struct_value () [concrete]
  96. // CHECK:STDOUT: %A.ed7: type = class_type @A, @A(%empty_struct_type) [concrete]
  97. // CHECK:STDOUT: %ptr.ed2: type = ptr_type %A.ed7 [concrete]
  98. // CHECK:STDOUT: %ptr.c28: type = ptr_type %empty_struct_type [concrete]
  99. // CHECK:STDOUT: %.9ba: Core.Form = init_form %ptr.c28 [concrete]
  100. // CHECK:STDOUT: %pattern_type.1cc: type = pattern_type %ptr.c28 [concrete]
  101. // CHECK:STDOUT: %I.type.ab5: type = facet_type <@I, @I(%empty_struct_type)> [concrete]
  102. // CHECK:STDOUT: %I.assoc_type.294: type = assoc_entity_type @I, @I(%empty_struct_type) [concrete]
  103. // CHECK:STDOUT: %assoc0.c64: %I.assoc_type.294 = assoc_entity element0, @I.WithSelf.%I.WithSelf.F.decl [concrete]
  104. // CHECK:STDOUT: %I.impl_witness.708: <witness> = impl_witness @A.as.I.impl.%I.impl_witness_table, @A.as.I.impl(%empty_struct_type) [concrete]
  105. // CHECK:STDOUT: %complete_type.5b1: <witness> = complete_type_witness %I.type.ab5 [concrete]
  106. // CHECK:STDOUT: %A.as.I.impl.F.type.aa2: type = fn_type @A.as.I.impl.F, @A.as.I.impl(%empty_struct_type) [concrete]
  107. // CHECK:STDOUT: %A.as.I.impl.F.c38: %A.as.I.impl.F.type.aa2 = struct_value () [concrete]
  108. // CHECK:STDOUT: %I.facet.681: %I.type.ab5 = facet_value %A.ed7, (%I.impl_witness.708) [concrete]
  109. // CHECK:STDOUT: %I.WithSelf.F.type.d75: type = fn_type @I.WithSelf.F, @I.WithSelf(%empty_struct_type, %I.facet.681) [concrete]
  110. // CHECK:STDOUT: %.d59: type = fn_type_with_self_type %I.WithSelf.F.type.d75, %I.facet.681 [concrete]
  111. // CHECK:STDOUT: %pattern_type.853: type = pattern_type %A.ed7 [concrete]
  112. // CHECK:STDOUT: %A.as.I.impl.F.specific_fn: <specific function> = specific_function %A.as.I.impl.F.c38, @A.as.I.impl.F(%empty_struct_type) [concrete]
  113. // CHECK:STDOUT: %A.elem.599: type = unbound_element_type %A.ed7, %empty_struct_type [concrete]
  114. // CHECK:STDOUT: %struct_type.n.91c: type = struct_type {.n: %empty_struct_type} [concrete]
  115. // CHECK:STDOUT: %complete_type.0a6: <witness> = complete_type_witness %struct_type.n.91c [concrete]
  116. // CHECK:STDOUT: %complete_type.38e: <witness> = complete_type_witness %ptr.c28 [concrete]
  117. // CHECK:STDOUT: %Copy.impl_witness.3fd: <witness> = impl_witness imports.%Copy.impl_witness_table.c3a, @ptr.as.Copy.impl(%empty_struct_type) [concrete]
  118. // CHECK:STDOUT: %ptr.as.Copy.impl.Op.type.032: type = fn_type @ptr.as.Copy.impl.Op, @ptr.as.Copy.impl(%empty_struct_type) [concrete]
  119. // CHECK:STDOUT: %ptr.as.Copy.impl.Op.cbf: %ptr.as.Copy.impl.Op.type.032 = struct_value () [concrete]
  120. // CHECK:STDOUT: %.07c: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%empty_struct_type) [concrete]
  121. // CHECK:STDOUT: %Copy.facet.111: %Copy.type = facet_value %ptr.c28, (%Copy.impl_witness.3fd) [concrete]
  122. // CHECK:STDOUT: %Copy.WithSelf.Op.type.514: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet.111) [concrete]
  123. // CHECK:STDOUT: %.237: type = fn_type_with_self_type %Copy.WithSelf.Op.type.514, %Copy.facet.111 [concrete]
  124. // CHECK:STDOUT: %ptr.as.Copy.impl.Op.specific_fn: <specific function> = specific_function %ptr.as.Copy.impl.Op.cbf, @ptr.as.Copy.impl.Op(%empty_struct_type) [concrete]
  125. // CHECK:STDOUT: }
  126. // CHECK:STDOUT:
  127. // CHECK:STDOUT: imports {
  128. // CHECK:STDOUT: %Core.import_ref.203: @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op.type (%ptr.as.Copy.impl.Op.type.2d4455.1) = import_ref Core//prelude/parts/copy, loc{{\d+_\d+}}, loaded [symbolic = @ptr.as.Copy.impl.%ptr.as.Copy.impl.Op (constants.%ptr.as.Copy.impl.Op.74e93b.1)]
  129. // CHECK:STDOUT: %Copy.impl_witness_table.c3a = impl_witness_table (%Core.import_ref.203), @ptr.as.Copy.impl [concrete]
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: file {
  133. // CHECK:STDOUT: impl_decl @A.as.I.impl [concrete] {
  134. // CHECK:STDOUT: %V.patt: %pattern_type.98f = symbolic_binding_pattern V, 0 [concrete]
  135. // CHECK:STDOUT: } {
  136. // CHECK:STDOUT: %A.ref: %A.type = name_ref A, file.%A.decl [concrete = constants.%A.generic]
  137. // CHECK:STDOUT: %V.ref.loc12_26: type = name_ref V, %V.loc12_15.2 [symbolic = %V.loc12_15.1 (constants.%V.67d)]
  138. // CHECK:STDOUT: %A.loc12_27.2: type = class_type @A, @A(constants.%V.67d) [symbolic = %A.loc12_27.1 (constants.%A.95c0c7.2)]
  139. // CHECK:STDOUT: %I.ref: %I.type.609 = name_ref I, file.%I.decl [concrete = constants.%I.generic]
  140. // CHECK:STDOUT: %V.ref.loc12_34: type = name_ref V, %V.loc12_15.2 [symbolic = %V.loc12_15.1 (constants.%V.67d)]
  141. // CHECK:STDOUT: %I.type.loc12_35.2: type = facet_type <@I, @I(constants.%V.67d)> [symbolic = %I.type.loc12_35.1 (constants.%I.type.1ab3e4.2)]
  142. // CHECK:STDOUT: %.loc12_18.1: type = splice_block %.loc12_18.2 [concrete = type] {
  143. // CHECK:STDOUT: <elided>
  144. // CHECK:STDOUT: %.loc12_18.2: type = type_literal type [concrete = type]
  145. // CHECK:STDOUT: }
  146. // CHECK:STDOUT: %V.loc12_15.2: type = symbolic_binding V, 0 [symbolic = %V.loc12_15.1 (constants.%V.67d)]
  147. // CHECK:STDOUT: }
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: generic impl @A.as.I.impl(%V.loc12_15.2: type) {
  151. // CHECK:STDOUT: %V.loc12_15.1: type = symbolic_binding V, 0 [symbolic = %V.loc12_15.1 (constants.%V.67d)]
  152. // CHECK:STDOUT: %A.loc12_27.1: type = class_type @A, @A(%V.loc12_15.1) [symbolic = %A.loc12_27.1 (constants.%A.95c0c7.2)]
  153. // CHECK:STDOUT: %I.type.loc12_35.1: type = facet_type <@I, @I(%V.loc12_15.1)> [symbolic = %I.type.loc12_35.1 (constants.%I.type.1ab3e4.2)]
  154. // CHECK:STDOUT: %I.impl_witness.loc12_37.2: <witness> = impl_witness %I.impl_witness_table, @A.as.I.impl(%V.loc12_15.1) [symbolic = %I.impl_witness.loc12_37.2 (constants.%I.impl_witness.f3f3bd.1)]
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: !definition:
  157. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %I.type.loc12_35.1 [symbolic = %require_complete (constants.%require_complete.e360af.1)]
  158. // CHECK:STDOUT: %A.as.I.impl.F.type: type = fn_type @A.as.I.impl.F, @A.as.I.impl(%V.loc12_15.1) [symbolic = %A.as.I.impl.F.type (constants.%A.as.I.impl.F.type.58747b.1)]
  159. // CHECK:STDOUT: %A.as.I.impl.F: @A.as.I.impl.%A.as.I.impl.F.type (%A.as.I.impl.F.type.58747b.1) = struct_value () [symbolic = %A.as.I.impl.F (constants.%A.as.I.impl.F.afeb91.1)]
  160. // CHECK:STDOUT:
  161. // CHECK:STDOUT: impl: %A.loc12_27.2 as %I.type.loc12_35.2 {
  162. // CHECK:STDOUT: %A.as.I.impl.F.decl: @A.as.I.impl.%A.as.I.impl.F.type (%A.as.I.impl.F.type.58747b.1) = fn_decl @A.as.I.impl.F [symbolic = @A.as.I.impl.%A.as.I.impl.F (constants.%A.as.I.impl.F.afeb91.1)] {
  163. // CHECK:STDOUT: %self.param_patt: @A.as.I.impl.F.%pattern_type.loc13_16 (%pattern_type.2c404c.1) = ref_param_pattern [concrete]
  164. // CHECK:STDOUT: %self.patt: @A.as.I.impl.F.%pattern_type.loc13_16 (%pattern_type.2c404c.1) = at_binding_pattern self, %self.param_patt [concrete]
  165. // CHECK:STDOUT: %return.param_patt: @A.as.I.impl.F.%pattern_type.loc13_30 (%pattern_type.4f4b84.2) = out_param_pattern [concrete]
  166. // CHECK:STDOUT: %return.patt: @A.as.I.impl.F.%pattern_type.loc13_30 (%pattern_type.4f4b84.2) = return_slot_pattern %return.param_patt, %ptr.loc13_30.2 [concrete]
  167. // CHECK:STDOUT: } {
  168. // CHECK:STDOUT: %V.ref: type = name_ref V, @A.as.I.impl.%V.loc12_15.2 [symbolic = %V (constants.%V.67d)]
  169. // CHECK:STDOUT: %ptr.loc13_30.2: type = ptr_type %V.ref [symbolic = %ptr.loc13_30.1 (constants.%ptr.e8f8f9.2)]
  170. // CHECK:STDOUT: %.loc13_30.2: Core.Form = init_form %ptr.loc13_30.2 [symbolic = %.loc13_30.1 (constants.%.cb6cb9.2)]
  171. // CHECK:STDOUT: %self.param: ref @A.as.I.impl.F.%A (%A.95c0c7.2) = ref_param call_param0
  172. // CHECK:STDOUT: %Self.ref: type = name_ref Self, @A.as.I.impl.%A.loc12_27.2 [symbolic = %A (constants.%A.95c0c7.2)]
  173. // CHECK:STDOUT: %self: ref @A.as.I.impl.F.%A (%A.95c0c7.2) = ref_binding self, %self.param
  174. // CHECK:STDOUT: %return.param: ref @A.as.I.impl.F.%ptr.loc13_30.1 (%ptr.e8f8f9.2) = out_param call_param1
  175. // CHECK:STDOUT: %return: ref @A.as.I.impl.F.%ptr.loc13_30.1 (%ptr.e8f8f9.2) = return_slot %return.param
  176. // CHECK:STDOUT: }
  177. // CHECK:STDOUT: %I.impl_witness_table = impl_witness_table (%A.as.I.impl.F.decl), @A.as.I.impl [concrete]
  178. // CHECK:STDOUT: %I.impl_witness.loc12_37.1: <witness> = impl_witness %I.impl_witness_table, @A.as.I.impl(constants.%V.67d) [symbolic = %I.impl_witness.loc12_37.2 (constants.%I.impl_witness.f3f3bd.1)]
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: !members:
  181. // CHECK:STDOUT: .V = <poisoned>
  182. // CHECK:STDOUT: .F = %A.as.I.impl.F.decl
  183. // CHECK:STDOUT: witness = %I.impl_witness.loc12_37.1
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT: }
  186. // CHECK:STDOUT:
  187. // CHECK:STDOUT: generic fn @A.as.I.impl.F(@A.as.I.impl.%V.loc12_15.2: type) {
  188. // CHECK:STDOUT: %V: type = symbolic_binding V, 0 [symbolic = %V (constants.%V.67d)]
  189. // CHECK:STDOUT: %A: type = class_type @A, @A(%V) [symbolic = %A (constants.%A.95c0c7.2)]
  190. // CHECK:STDOUT: %pattern_type.loc13_16: type = pattern_type %A [symbolic = %pattern_type.loc13_16 (constants.%pattern_type.2c404c.1)]
  191. // CHECK:STDOUT: %ptr.loc13_30.1: type = ptr_type %V [symbolic = %ptr.loc13_30.1 (constants.%ptr.e8f8f9.2)]
  192. // CHECK:STDOUT: %.loc13_30.1: Core.Form = init_form %ptr.loc13_30.1 [symbolic = %.loc13_30.1 (constants.%.cb6cb9.2)]
  193. // CHECK:STDOUT: %pattern_type.loc13_30: type = pattern_type %ptr.loc13_30.1 [symbolic = %pattern_type.loc13_30 (constants.%pattern_type.4f4b84.2)]
  194. // CHECK:STDOUT:
  195. // CHECK:STDOUT: !definition:
  196. // CHECK:STDOUT: %require_complete.loc13_16: <witness> = require_complete_type %A [symbolic = %require_complete.loc13_16 (constants.%require_complete.fd6)]
  197. // CHECK:STDOUT: %require_complete.loc13_26: <witness> = require_complete_type %ptr.loc13_30.1 [symbolic = %require_complete.loc13_26 (constants.%require_complete.ef162c.1)]
  198. // CHECK:STDOUT: %A.elem: type = unbound_element_type %A, %V [symbolic = %A.elem (constants.%A.elem.8a20fa.2)]
  199. // CHECK:STDOUT: %.loc14_12.1: require_specific_def_type = require_specific_def @ptr.as.Copy.impl(%V) [symbolic = %.loc14_12.1 (constants.%.2f2)]
  200. // CHECK:STDOUT: %Copy.lookup_impl_witness: <witness> = lookup_impl_witness %ptr.loc13_30.1, @Copy [symbolic = %Copy.lookup_impl_witness (constants.%Copy.lookup_impl_witness.2e6)]
  201. // CHECK:STDOUT: %Copy.facet: %Copy.type = facet_value %ptr.loc13_30.1, (%Copy.lookup_impl_witness) [symbolic = %Copy.facet (constants.%Copy.facet.c25)]
  202. // CHECK:STDOUT: %Copy.WithSelf.Op.type: type = fn_type @Copy.WithSelf.Op, @Copy.WithSelf(%Copy.facet) [symbolic = %Copy.WithSelf.Op.type (constants.%Copy.WithSelf.Op.type.d82)]
  203. // CHECK:STDOUT: %.loc14_12.2: type = fn_type_with_self_type %Copy.WithSelf.Op.type, %Copy.facet [symbolic = %.loc14_12.2 (constants.%.299)]
  204. // CHECK:STDOUT: %impl.elem0.loc14_12.2: @A.as.I.impl.F.%.loc14_12.2 (%.299) = impl_witness_access %Copy.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc14_12.2 (constants.%impl.elem0.1c7)]
  205. // CHECK:STDOUT: %specific_impl_fn.loc14_12.2: <specific function> = specific_impl_function %impl.elem0.loc14_12.2, @Copy.WithSelf.Op(%Copy.facet) [symbolic = %specific_impl_fn.loc14_12.2 (constants.%specific_impl_fn.366)]
  206. // CHECK:STDOUT:
  207. // CHECK:STDOUT: fn(%self.param: ref @A.as.I.impl.F.%A (%A.95c0c7.2)) -> out %return.param: @A.as.I.impl.F.%ptr.loc13_30.1 (%ptr.e8f8f9.2) {
  208. // CHECK:STDOUT: !entry:
  209. // CHECK:STDOUT: %self.ref: ref @A.as.I.impl.F.%A (%A.95c0c7.2) = name_ref self, %self
  210. // CHECK:STDOUT: %n.ref: @A.as.I.impl.F.%A.elem (%A.elem.8a20fa.2) = name_ref n, @A.%.loc4 [concrete = @A.%.loc4]
  211. // CHECK:STDOUT: %.loc14_17: ref @A.as.I.impl.F.%V (%V.67d) = class_element_access %self.ref, element0
  212. // CHECK:STDOUT: %addr: @A.as.I.impl.F.%ptr.loc13_30.1 (%ptr.e8f8f9.2) = addr_of %.loc14_17
  213. // CHECK:STDOUT: %impl.elem0.loc14_12.1: @A.as.I.impl.F.%.loc14_12.2 (%.299) = impl_witness_access constants.%Copy.lookup_impl_witness.2e6, element0 [symbolic = %impl.elem0.loc14_12.2 (constants.%impl.elem0.1c7)]
  214. // CHECK:STDOUT: %bound_method.loc14_12.1: <bound method> = bound_method %addr, %impl.elem0.loc14_12.1
  215. // CHECK:STDOUT: %specific_impl_fn.loc14_12.1: <specific function> = specific_impl_function %impl.elem0.loc14_12.1, @Copy.WithSelf.Op(constants.%Copy.facet.c25) [symbolic = %specific_impl_fn.loc14_12.2 (constants.%specific_impl_fn.366)]
  216. // CHECK:STDOUT: %bound_method.loc14_12.2: <bound method> = bound_method %addr, %specific_impl_fn.loc14_12.1
  217. // CHECK:STDOUT: %Copy.WithSelf.Op.call: init @A.as.I.impl.F.%ptr.loc13_30.1 (%ptr.e8f8f9.2) = call %bound_method.loc14_12.2(%addr)
  218. // CHECK:STDOUT: return %Copy.WithSelf.Op.call
  219. // CHECK:STDOUT: }
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: generic fn @TestGeneric(%W.loc19_17.2: type) {
  223. // CHECK:STDOUT: <elided>
  224. // CHECK:STDOUT:
  225. // CHECK:STDOUT: !definition:
  226. // CHECK:STDOUT: <elided>
  227. // CHECK:STDOUT: %I.type.loc21_17.2: type = facet_type <@I, @I(%W.loc19_17.1)> [symbolic = %I.type.loc21_17.2 (constants.%I.type.1ab3e4.3)]
  228. // CHECK:STDOUT: %require_complete.loc21: <witness> = require_complete_type %I.type.loc21_17.2 [symbolic = %require_complete.loc21 (constants.%require_complete.e360af.2)]
  229. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I, @I(%W.loc19_17.1) [symbolic = %I.assoc_type (constants.%I.assoc_type.76c031.3)]
  230. // CHECK:STDOUT: %assoc0: @TestGeneric.%I.assoc_type (%I.assoc_type.76c031.3) = assoc_entity element0, @I.WithSelf.%I.WithSelf.F.decl [symbolic = %assoc0 (constants.%assoc0.203667.3)]
  231. // CHECK:STDOUT: %.loc21_11.2: require_specific_def_type = require_specific_def @A.as.I.impl(%W.loc19_17.1) [symbolic = %.loc21_11.2 (constants.%.0fe)]
  232. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %A.loc19_32.1, @I, @I(%W.loc19_17.1) [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  233. // CHECK:STDOUT: %I.facet: @TestGeneric.%I.type.loc21_17.2 (%I.type.1ab3e4.3) = facet_value %A.loc19_32.1, (%I.lookup_impl_witness) [symbolic = %I.facet (constants.%I.facet.558)]
  234. // CHECK:STDOUT: %I.WithSelf.F.type: type = fn_type @I.WithSelf.F, @I.WithSelf(%W.loc19_17.1, %I.facet) [symbolic = %I.WithSelf.F.type (constants.%I.WithSelf.F.type.912)]
  235. // CHECK:STDOUT: %.loc21_11.3: type = fn_type_with_self_type %I.WithSelf.F.type, %I.facet [symbolic = %.loc21_11.3 (constants.%.695)]
  236. // CHECK:STDOUT: %impl.elem0.loc21_11.2: @TestGeneric.%.loc21_11.3 (%.695) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc21_11.2 (constants.%impl.elem0.976)]
  237. // CHECK:STDOUT: %specific_impl_fn.loc21_11.2: <specific function> = specific_impl_function %impl.elem0.loc21_11.2, @I.WithSelf.F(%W.loc19_17.1, %I.facet) [symbolic = %specific_impl_fn.loc21_11.2 (constants.%specific_impl_fn.3c2)]
  238. // CHECK:STDOUT:
  239. // CHECK:STDOUT: fn(%a.param: @TestGeneric.%ptr.loc19_33.1 (%ptr.5da)) -> out %return.param: @TestGeneric.%ptr.loc19_40.1 (%ptr.e8f8f9.4) {
  240. // CHECK:STDOUT: !entry:
  241. // CHECK:STDOUT: %a.ref: @TestGeneric.%ptr.loc19_33.1 (%ptr.5da) = name_ref a, %a
  242. // CHECK:STDOUT: %I.ref: %I.type.609 = name_ref I, file.%I.decl [concrete = constants.%I.generic]
  243. // CHECK:STDOUT: %W.ref.loc21: type = name_ref W, %W.loc19_17.2 [symbolic = %W.loc19_17.1 (constants.%W)]
  244. // CHECK:STDOUT: %I.type.loc21_17.1: type = facet_type <@I, @I(constants.%W)> [symbolic = %I.type.loc21_17.2 (constants.%I.type.1ab3e4.3)]
  245. // CHECK:STDOUT: %.loc21_18: @TestGeneric.%I.assoc_type (%I.assoc_type.76c031.3) = specific_constant @I.WithSelf.%assoc0.loc8_31.1, @I.WithSelf(constants.%W, constants.%Self.fdb544.1) [symbolic = %assoc0 (constants.%assoc0.203667.3)]
  246. // CHECK:STDOUT: %F.ref: @TestGeneric.%I.assoc_type (%I.assoc_type.76c031.3) = name_ref F, %.loc21_18 [symbolic = %assoc0 (constants.%assoc0.203667.3)]
  247. // CHECK:STDOUT: %.loc21_11.1: ref @TestGeneric.%A.loc19_32.1 (%A.95c0c7.3) = deref %a.ref
  248. // CHECK:STDOUT: %impl.elem0.loc21_11.1: @TestGeneric.%.loc21_11.3 (%.695) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc21_11.2 (constants.%impl.elem0.976)]
  249. // CHECK:STDOUT: %bound_method.loc21_11: <bound method> = bound_method %.loc21_11.1, %impl.elem0.loc21_11.1
  250. // CHECK:STDOUT: %specific_impl_fn.loc21_11.1: <specific function> = specific_impl_function %impl.elem0.loc21_11.1, @I.WithSelf.F(constants.%W, constants.%I.facet.558) [symbolic = %specific_impl_fn.loc21_11.2 (constants.%specific_impl_fn.3c2)]
  251. // CHECK:STDOUT: %bound_method.loc21_22: <bound method> = bound_method %.loc21_11.1, %specific_impl_fn.loc21_11.1
  252. // CHECK:STDOUT: %I.WithSelf.F.call: init @TestGeneric.%ptr.loc19_40.1 (%ptr.e8f8f9.4) = call %bound_method.loc21_22(%.loc21_11.1)
  253. // CHECK:STDOUT: return %I.WithSelf.F.call
  254. // CHECK:STDOUT: }
  255. // CHECK:STDOUT: }
  256. // CHECK:STDOUT:
  257. // CHECK:STDOUT: fn @TestSpecific(%a.param: %ptr.ed2) -> out %return.param: %ptr.c28 {
  258. // CHECK:STDOUT: !entry:
  259. // CHECK:STDOUT: %a.ref: %ptr.ed2 = name_ref a, %a
  260. // CHECK:STDOUT: %I.ref: %I.type.609 = name_ref I, file.%I.decl [concrete = constants.%I.generic]
  261. // CHECK:STDOUT: %.loc27_17: %empty_struct_type = struct_literal () [concrete = constants.%empty_struct]
  262. // CHECK:STDOUT: %.loc27_18: type = converted %.loc27_17, constants.%empty_struct_type [concrete = constants.%empty_struct_type]
  263. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%empty_struct_type)> [concrete = constants.%I.type.ab5]
  264. // CHECK:STDOUT: %.loc27_19: %I.assoc_type.294 = specific_constant @I.WithSelf.%assoc0.loc8_31.1, @I.WithSelf(constants.%empty_struct_type, constants.%Self.fdb544.1) [concrete = constants.%assoc0.c64]
  265. // CHECK:STDOUT: %F.ref: %I.assoc_type.294 = name_ref F, %.loc27_19 [concrete = constants.%assoc0.c64]
  266. // CHECK:STDOUT: %.loc27_11: ref %A.ed7 = deref %a.ref
  267. // CHECK:STDOUT: %impl.elem0: %.d59 = impl_witness_access constants.%I.impl_witness.708, element0 [concrete = constants.%A.as.I.impl.F.c38]
  268. // CHECK:STDOUT: %bound_method.loc27_11: <bound method> = bound_method %.loc27_11, %impl.elem0
  269. // CHECK:STDOUT: %specific_fn: <specific function> = specific_function %impl.elem0, @A.as.I.impl.F(constants.%empty_struct_type) [concrete = constants.%A.as.I.impl.F.specific_fn]
  270. // CHECK:STDOUT: %bound_method.loc27_23: <bound method> = bound_method %.loc27_11, %specific_fn
  271. // CHECK:STDOUT: %A.as.I.impl.F.call: init %ptr.c28 = call %bound_method.loc27_23(%.loc27_11)
  272. // CHECK:STDOUT: return %A.as.I.impl.F.call
  273. // CHECK:STDOUT: }
  274. // CHECK:STDOUT:
  275. // CHECK:STDOUT: specific @A.as.I.impl(constants.%V.67d) {
  276. // CHECK:STDOUT: %V.loc12_15.1 => constants.%V.67d
  277. // CHECK:STDOUT: %A.loc12_27.1 => constants.%A.95c0c7.2
  278. // CHECK:STDOUT: %I.type.loc12_35.1 => constants.%I.type.1ab3e4.2
  279. // CHECK:STDOUT: %I.impl_witness.loc12_37.2 => constants.%I.impl_witness.f3f3bd.1
  280. // CHECK:STDOUT:
  281. // CHECK:STDOUT: !definition:
  282. // CHECK:STDOUT: %require_complete => constants.%require_complete.e360af.1
  283. // CHECK:STDOUT: %A.as.I.impl.F.type => constants.%A.as.I.impl.F.type.58747b.1
  284. // CHECK:STDOUT: %A.as.I.impl.F => constants.%A.as.I.impl.F.afeb91.1
  285. // CHECK:STDOUT: }
  286. // CHECK:STDOUT:
  287. // CHECK:STDOUT: specific @A.as.I.impl.F(constants.%V.67d) {
  288. // CHECK:STDOUT: %V => constants.%V.67d
  289. // CHECK:STDOUT: %A => constants.%A.95c0c7.2
  290. // CHECK:STDOUT: %pattern_type.loc13_16 => constants.%pattern_type.2c404c.1
  291. // CHECK:STDOUT: %ptr.loc13_30.1 => constants.%ptr.e8f8f9.2
  292. // CHECK:STDOUT: %.loc13_30.1 => constants.%.cb6cb9.2
  293. // CHECK:STDOUT: %pattern_type.loc13_30 => constants.%pattern_type.4f4b84.2
  294. // CHECK:STDOUT: }
  295. // CHECK:STDOUT:
  296. // CHECK:STDOUT: specific @TestGeneric(constants.%W) {
  297. // CHECK:STDOUT: %W.loc19_17.1 => constants.%W
  298. // CHECK:STDOUT: %A.loc19_32.1 => constants.%A.95c0c7.3
  299. // CHECK:STDOUT: %ptr.loc19_33.1 => constants.%ptr.5da
  300. // CHECK:STDOUT: %pattern_type.loc19_27 => constants.%pattern_type.605
  301. // CHECK:STDOUT: %ptr.loc19_40.1 => constants.%ptr.e8f8f9.4
  302. // CHECK:STDOUT: %.loc19_40.1 => constants.%.cb6cb9.4
  303. // CHECK:STDOUT: %pattern_type.loc19_40 => constants.%pattern_type.4f4b84.4
  304. // CHECK:STDOUT: }
  305. // CHECK:STDOUT:
  306. // CHECK:STDOUT: specific @A.as.I.impl(constants.%W) {
  307. // CHECK:STDOUT: %V.loc12_15.1 => constants.%W
  308. // CHECK:STDOUT: %A.loc12_27.1 => constants.%A.95c0c7.3
  309. // CHECK:STDOUT: %I.type.loc12_35.1 => constants.%I.type.1ab3e4.3
  310. // CHECK:STDOUT: %I.impl_witness.loc12_37.2 => constants.%I.impl_witness.f3f3bd.2
  311. // CHECK:STDOUT:
  312. // CHECK:STDOUT: !definition:
  313. // CHECK:STDOUT: %require_complete => constants.%require_complete.e360af.2
  314. // CHECK:STDOUT: %A.as.I.impl.F.type => constants.%A.as.I.impl.F.type.58747b.2
  315. // CHECK:STDOUT: %A.as.I.impl.F => constants.%A.as.I.impl.F.afeb91.2
  316. // CHECK:STDOUT: }
  317. // CHECK:STDOUT:
  318. // CHECK:STDOUT: specific @A.as.I.impl(constants.%empty_struct_type) {
  319. // CHECK:STDOUT: %V.loc12_15.1 => constants.%empty_struct_type
  320. // CHECK:STDOUT: %A.loc12_27.1 => constants.%A.ed7
  321. // CHECK:STDOUT: %I.type.loc12_35.1 => constants.%I.type.ab5
  322. // CHECK:STDOUT: %I.impl_witness.loc12_37.2 => constants.%I.impl_witness.708
  323. // CHECK:STDOUT:
  324. // CHECK:STDOUT: !definition:
  325. // CHECK:STDOUT: %require_complete => constants.%complete_type.5b1
  326. // CHECK:STDOUT: %A.as.I.impl.F.type => constants.%A.as.I.impl.F.type.aa2
  327. // CHECK:STDOUT: %A.as.I.impl.F => constants.%A.as.I.impl.F.c38
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: specific @A.as.I.impl.F(constants.%empty_struct_type) {
  331. // CHECK:STDOUT: %V => constants.%empty_struct_type
  332. // CHECK:STDOUT: %A => constants.%A.ed7
  333. // CHECK:STDOUT: %pattern_type.loc13_16 => constants.%pattern_type.853
  334. // CHECK:STDOUT: %ptr.loc13_30.1 => constants.%ptr.c28
  335. // CHECK:STDOUT: %.loc13_30.1 => constants.%.9ba
  336. // CHECK:STDOUT: %pattern_type.loc13_30 => constants.%pattern_type.1cc
  337. // CHECK:STDOUT:
  338. // CHECK:STDOUT: !definition:
  339. // CHECK:STDOUT: %require_complete.loc13_16 => constants.%complete_type.0a6
  340. // CHECK:STDOUT: %require_complete.loc13_26 => constants.%complete_type.38e
  341. // CHECK:STDOUT: %A.elem => constants.%A.elem.599
  342. // CHECK:STDOUT: %.loc14_12.1 => constants.%.07c
  343. // CHECK:STDOUT: %Copy.lookup_impl_witness => constants.%Copy.impl_witness.3fd
  344. // CHECK:STDOUT: %Copy.facet => constants.%Copy.facet.111
  345. // CHECK:STDOUT: %Copy.WithSelf.Op.type => constants.%Copy.WithSelf.Op.type.514
  346. // CHECK:STDOUT: %.loc14_12.2 => constants.%.237
  347. // CHECK:STDOUT: %impl.elem0.loc14_12.2 => constants.%ptr.as.Copy.impl.Op.cbf
  348. // CHECK:STDOUT: %specific_impl_fn.loc14_12.2 => constants.%ptr.as.Copy.impl.Op.specific_fn
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT: