self_in_interface_param.carbon 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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/none.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/facet/self_in_interface_param.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/self_in_interface_param.carbon
  12. interface I(T:! type) {
  13. let I1:! type;
  14. }
  15. //@dump-sem-ir-begin
  16. fn F(T:! I(.Self) where .I1 = ()) -> T.I1 {
  17. return ();
  18. }
  19. //@dump-sem-ir-end
  20. fn G(_:! I(.Self) where .I1 = ()) {}
  21. // CHECK:STDOUT: --- self_in_interface_param.carbon
  22. // CHECK:STDOUT:
  23. // CHECK:STDOUT: constants {
  24. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  25. // CHECK:STDOUT: %.Self.c39: %type = symbolic_binding .Self [symbolic_self]
  26. // CHECK:STDOUT: %I.type.609: type = generic_interface_type @I [concrete]
  27. // CHECK:STDOUT: %empty_tuple.type: type = tuple_type () [concrete]
  28. // CHECK:STDOUT: %I.generic: %I.type.609 = struct_value () [concrete]
  29. // CHECK:STDOUT: %.Self.binding.as_type.8db: type = symbolic_binding_type .Self, %.Self.c39 [symbolic_self]
  30. // CHECK:STDOUT: %I.type.bee: type = facet_type <@I, @I(%.Self.binding.as_type.8db)> [symbolic_self]
  31. // CHECK:STDOUT: %.Self.dad: %I.type.bee = symbolic_binding .Self [symbolic_self]
  32. // CHECK:STDOUT: %I.assoc_type.c03: type = assoc_entity_type @I, @I(%.Self.binding.as_type.8db) [symbolic_self]
  33. // CHECK:STDOUT: %assoc0.2f7: %I.assoc_type.c03 = assoc_entity element0, @I.%I1 [symbolic_self]
  34. // CHECK:STDOUT: %.Self.binding.as_type.b0b: type = symbolic_binding_type .Self, %.Self.dad [symbolic_self]
  35. // CHECK:STDOUT: %I.lookup_impl_witness.3fc: <witness> = lookup_impl_witness %.Self.dad, @I, @I(%.Self.binding.as_type.8db) [symbolic_self]
  36. // CHECK:STDOUT: %impl.elem0: type = impl_witness_access %I.lookup_impl_witness.3fc, element0 [symbolic_self]
  37. // CHECK:STDOUT: %empty_tuple: %empty_tuple.type = tuple_value () [concrete]
  38. // CHECK:STDOUT: %I_where.type: type = facet_type <@I, @I(%.Self.binding.as_type.8db) where %impl.elem0 = %empty_tuple.type> [symbolic_self]
  39. // CHECK:STDOUT: %T.706: %I_where.type = symbolic_binding T, 0 [symbolic]
  40. // CHECK:STDOUT: %pattern_type.033: type = pattern_type %I_where.type [symbolic_self]
  41. // CHECK:STDOUT: %T.binding.as_type: type = symbolic_binding_type T, 0, %T.706 [symbolic]
  42. // CHECK:STDOUT: %I.lookup_impl_witness.94d: <witness> = lookup_impl_witness %T.706, @I, @I(%.Self.binding.as_type.8db) [symbolic]
  43. // CHECK:STDOUT: %.842: Core.Form = init_form %empty_tuple.type, call_param0 [concrete]
  44. // CHECK:STDOUT: %pattern_type.cb1: type = pattern_type %empty_tuple.type [concrete]
  45. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  46. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: file {
  50. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  51. // CHECK:STDOUT: %T.patt: %pattern_type.033 = symbolic_binding_pattern T, 0 [concrete]
  52. // CHECK:STDOUT: %return.patt: %pattern_type.cb1 = return_slot_pattern [concrete]
  53. // CHECK:STDOUT: %return.param_patt: %pattern_type.cb1 = out_param_pattern %return.patt, call_param0 [concrete]
  54. // CHECK:STDOUT: } {
  55. // CHECK:STDOUT: %T.ref: %I_where.type = name_ref T, %T.loc18_6.2 [symbolic = %T.loc18_6.1 (constants.%T.706)]
  56. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T.ref [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  57. // CHECK:STDOUT: %.loc18_39.1: type = converted %T.ref, %T.as_type [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  58. // CHECK:STDOUT: %.loc18_39.2: %I.assoc_type.c03 = specific_constant @I1.%assoc0, @I(constants.%.Self.binding.as_type.8db) [symbolic_self = constants.%assoc0.2f7]
  59. // CHECK:STDOUT: %I1.ref.loc18_39: %I.assoc_type.c03 = name_ref I1, %.loc18_39.2 [symbolic_self = constants.%assoc0.2f7]
  60. // CHECK:STDOUT: %impl.elem0.loc18_39: type = impl_witness_access constants.%I.lookup_impl_witness.94d, element0 [concrete = constants.%empty_tuple.type]
  61. // CHECK:STDOUT: %.loc18_39.3: Core.Form = init_form %impl.elem0.loc18_39, call_param0 [concrete = constants.%.842]
  62. // CHECK:STDOUT: %.loc18_19.1: type = splice_block %.loc18_19.2 [symbolic_self = constants.%I_where.type] {
  63. // CHECK:STDOUT: <elided>
  64. // CHECK:STDOUT: %I.ref: %I.type.609 = name_ref I, file.%I.decl [concrete = constants.%I.generic]
  65. // CHECK:STDOUT: %.Self.ref.loc18_12: %type = name_ref .Self, %.Self.1 [symbolic_self = constants.%.Self.c39]
  66. // CHECK:STDOUT: %.Self.as_type.loc18_17: type = facet_access_type %.Self.ref.loc18_12 [symbolic_self = constants.%.Self.binding.as_type.8db]
  67. // CHECK:STDOUT: %.loc18_17: type = converted %.Self.ref.loc18_12, %.Self.as_type.loc18_17 [symbolic_self = constants.%.Self.binding.as_type.8db]
  68. // CHECK:STDOUT: %I.type: type = facet_type <@I, @I(constants.%.Self.binding.as_type.8db)> [symbolic_self = constants.%I.type.bee]
  69. // CHECK:STDOUT: <elided>
  70. // CHECK:STDOUT: %.Self.ref.loc18_25: %I.type.bee = name_ref .Self, %.Self.2 [symbolic_self = constants.%.Self.dad]
  71. // CHECK:STDOUT: %.Self.as_type.loc18_25: type = facet_access_type %.Self.ref.loc18_25 [symbolic_self = constants.%.Self.binding.as_type.b0b]
  72. // CHECK:STDOUT: %.loc18_25.1: type = converted %.Self.ref.loc18_25, %.Self.as_type.loc18_25 [symbolic_self = constants.%.Self.binding.as_type.b0b]
  73. // CHECK:STDOUT: %.loc18_25.2: %I.assoc_type.c03 = specific_constant @I1.%assoc0, @I(constants.%.Self.binding.as_type.8db) [symbolic_self = constants.%assoc0.2f7]
  74. // CHECK:STDOUT: %I1.ref.loc18_25: %I.assoc_type.c03 = name_ref I1, %.loc18_25.2 [symbolic_self = constants.%assoc0.2f7]
  75. // CHECK:STDOUT: %impl.elem0.loc18_25: type = impl_witness_access constants.%I.lookup_impl_witness.3fc, element0 [symbolic_self = constants.%impl.elem0]
  76. // CHECK:STDOUT: %.loc18_32.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  77. // CHECK:STDOUT: %.loc18_32.2: type = converted %.loc18_32.1, constants.%empty_tuple.type [concrete = constants.%empty_tuple.type]
  78. // CHECK:STDOUT: %.loc18_19.2: type = where_expr %.Self.2 [symbolic_self = constants.%I_where.type] {
  79. // CHECK:STDOUT: requirement_base_facet_type constants.%I.type.bee
  80. // CHECK:STDOUT: requirement_rewrite %impl.elem0.loc18_25, %.loc18_32.2
  81. // CHECK:STDOUT: }
  82. // CHECK:STDOUT: }
  83. // CHECK:STDOUT: %T.loc18_6.2: %I_where.type = symbolic_binding T, 0 [symbolic = %T.loc18_6.1 (constants.%T.706)]
  84. // CHECK:STDOUT: %return.param: ref %empty_tuple.type = out_param call_param0
  85. // CHECK:STDOUT: %return: ref %empty_tuple.type = return_slot %return.param
  86. // CHECK:STDOUT: }
  87. // CHECK:STDOUT: }
  88. // CHECK:STDOUT:
  89. // CHECK:STDOUT: generic fn @F(%T.loc18_6.2: %I_where.type) {
  90. // CHECK:STDOUT: %T.loc18_6.1: %I_where.type = symbolic_binding T, 0 [symbolic = %T.loc18_6.1 (constants.%T.706)]
  91. // CHECK:STDOUT: %T.binding.as_type: type = symbolic_binding_type T, 0, %T.loc18_6.1 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  92. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc18_6.1, @I, @I(constants.%.Self.binding.as_type.8db) [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness.94d)]
  93. // CHECK:STDOUT:
  94. // CHECK:STDOUT: !definition:
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: fn() -> out %return.param: %empty_tuple.type {
  97. // CHECK:STDOUT: !entry:
  98. // CHECK:STDOUT: %.loc19_11.1: %empty_tuple.type = tuple_literal () [concrete = constants.%empty_tuple]
  99. // CHECK:STDOUT: %.loc19_11.2: init %empty_tuple.type = tuple_init () [concrete = constants.%empty_tuple]
  100. // CHECK:STDOUT: %.loc19_12: init %empty_tuple.type = converted %.loc19_11.1, %.loc19_11.2 [concrete = constants.%empty_tuple]
  101. // CHECK:STDOUT: return %.loc19_12
  102. // CHECK:STDOUT: }
  103. // CHECK:STDOUT: }
  104. // CHECK:STDOUT:
  105. // CHECK:STDOUT: specific @F(constants.%T.706) {
  106. // CHECK:STDOUT: %T.loc18_6.1 => constants.%T.706
  107. // CHECK:STDOUT: %T.binding.as_type => constants.%T.binding.as_type
  108. // CHECK:STDOUT: %I.lookup_impl_witness => constants.%I.lookup_impl_witness.94d
  109. // CHECK:STDOUT: }
  110. // CHECK:STDOUT: