fail_assoc_fn_invalid_use.carbon 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. // 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/interface/fail_assoc_fn_invalid_use.carbon
  12. // TIP: To dump output, run:
  13. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/interface/fail_assoc_fn_invalid_use.carbon
  14. // --- fail_member_access.carbon
  15. library "[[@TEST_NAME]]";
  16. interface I {
  17. fn F[self: Self]();
  18. }
  19. fn Use(T:! I) {
  20. // CHECK:STDERR: fail_member_access.carbon:[[@LINE+4]]:3: error: type `<type of F in T as I>` does not support qualified expressions [QualifiedExprUnsupported]
  21. // CHECK:STDERR: T.F.member;
  22. // CHECK:STDERR: ^~~~~~~~~~
  23. // CHECK:STDERR:
  24. T.F.member;
  25. }
  26. // CHECK:STDOUT: --- fail_member_access.carbon
  27. // CHECK:STDOUT:
  28. // CHECK:STDOUT: constants {
  29. // CHECK:STDOUT: %I.type: type = facet_type <@I> [concrete]
  30. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic]
  31. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self [symbolic]
  32. // CHECK:STDOUT: %pattern_type.6de: type = pattern_type %Self.as_type [symbolic]
  33. // CHECK:STDOUT: %F.type: type = fn_type @F [concrete]
  34. // CHECK:STDOUT: %F: %F.type = struct_value () [concrete]
  35. // CHECK:STDOUT: %I.assoc_type: type = assoc_entity_type @I [concrete]
  36. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, @I.%F.decl [concrete]
  37. // CHECK:STDOUT: %T: %I.type = bind_symbolic_name T, 0 [symbolic]
  38. // CHECK:STDOUT: %pattern_type.2b5: type = pattern_type %I.type [concrete]
  39. // CHECK:STDOUT: %Use.type: type = fn_type @Use [concrete]
  40. // CHECK:STDOUT: %Use: %Use.type = struct_value () [concrete]
  41. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T [symbolic]
  42. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  43. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type, (%I.lookup_impl_witness) [symbolic]
  44. // CHECK:STDOUT: %.ee1: type = fn_type_with_self_type %F.type, %I.facet [symbolic]
  45. // CHECK:STDOUT: %impl.elem0: %.ee1 = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  46. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %.ee1 [symbolic]
  47. // CHECK:STDOUT: }
  48. // CHECK:STDOUT:
  49. // CHECK:STDOUT: file {
  50. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  51. // CHECK:STDOUT: .I = %I.decl
  52. // CHECK:STDOUT: .Use = %Use.decl
  53. // CHECK:STDOUT: }
  54. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  55. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [concrete = constants.%Use] {
  56. // CHECK:STDOUT: %T.patt: %pattern_type.2b5 = symbolic_binding_pattern T, 0 [concrete]
  57. // CHECK:STDOUT: } {
  58. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  59. // CHECK:STDOUT: %T.loc8_8.1: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_8.2 (constants.%T)]
  60. // CHECK:STDOUT: }
  61. // CHECK:STDOUT: }
  62. // CHECK:STDOUT:
  63. // CHECK:STDOUT: interface @I {
  64. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = constants.%Self]
  65. // CHECK:STDOUT: %F.decl: %F.type = fn_decl @F [concrete = constants.%F] {
  66. // CHECK:STDOUT: %self.patt: @F.%pattern_type (%pattern_type.6de) = binding_pattern self [concrete]
  67. // CHECK:STDOUT: %self.param_patt: @F.%pattern_type (%pattern_type.6de) = value_param_pattern %self.patt, call_param0 [concrete]
  68. // CHECK:STDOUT: } {
  69. // CHECK:STDOUT: %self.param: @F.%Self.as_type.loc5_14.1 (%Self.as_type) = value_param call_param0
  70. // CHECK:STDOUT: %.loc5_14.1: type = splice_block %.loc5_14.2 [symbolic = %Self.as_type.loc5_14.1 (constants.%Self.as_type)] {
  71. // CHECK:STDOUT: %Self.ref: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self)]
  72. // CHECK:STDOUT: %Self.as_type.loc5_14.2: type = facet_access_type %Self.ref [symbolic = %Self.as_type.loc5_14.1 (constants.%Self.as_type)]
  73. // CHECK:STDOUT: %.loc5_14.2: type = converted %Self.ref, %Self.as_type.loc5_14.2 [symbolic = %Self.as_type.loc5_14.1 (constants.%Self.as_type)]
  74. // CHECK:STDOUT: }
  75. // CHECK:STDOUT: %self: @F.%Self.as_type.loc5_14.1 (%Self.as_type) = bind_name self, %self.param
  76. // CHECK:STDOUT: }
  77. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %F.decl [concrete = constants.%assoc0]
  78. // CHECK:STDOUT:
  79. // CHECK:STDOUT: !members:
  80. // CHECK:STDOUT: .Self = %Self
  81. // CHECK:STDOUT: .F = %assoc0
  82. // CHECK:STDOUT: witness = (%F.decl)
  83. // CHECK:STDOUT: }
  84. // CHECK:STDOUT:
  85. // CHECK:STDOUT: generic fn @F(@I.%Self: %I.type) {
  86. // CHECK:STDOUT: %Self: %I.type = bind_symbolic_name Self, 0 [symbolic = %Self (constants.%Self)]
  87. // CHECK:STDOUT: %Self.as_type.loc5_14.1: type = facet_access_type %Self [symbolic = %Self.as_type.loc5_14.1 (constants.%Self.as_type)]
  88. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.as_type.loc5_14.1 [symbolic = %pattern_type (constants.%pattern_type.6de)]
  89. // CHECK:STDOUT:
  90. // CHECK:STDOUT: fn(%self.param: @F.%Self.as_type.loc5_14.1 (%Self.as_type));
  91. // CHECK:STDOUT: }
  92. // CHECK:STDOUT:
  93. // CHECK:STDOUT: generic fn @Use(%T.loc8_8.1: %I.type) {
  94. // CHECK:STDOUT: %T.loc8_8.2: %I.type = bind_symbolic_name T, 0 [symbolic = %T.loc8_8.2 (constants.%T)]
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: !definition:
  97. // CHECK:STDOUT: %T.as_type.loc13_4.2: type = facet_access_type %T.loc8_8.2 [symbolic = %T.as_type.loc13_4.2 (constants.%T.as_type)]
  98. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc8_8.2, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  99. // CHECK:STDOUT: %I.facet: %I.type = facet_value %T.as_type.loc13_4.2, (%I.lookup_impl_witness) [symbolic = %I.facet (constants.%I.facet)]
  100. // CHECK:STDOUT: %.loc13_4.2: type = fn_type_with_self_type constants.%F.type, %I.facet [symbolic = %.loc13_4.2 (constants.%.ee1)]
  101. // CHECK:STDOUT: %impl.elem0.loc13_4.2: @Use.%.loc13_4.2 (%.ee1) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_4.2 (constants.%impl.elem0)]
  102. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %.loc13_4.2 [symbolic = %require_complete (constants.%require_complete)]
  103. // CHECK:STDOUT:
  104. // CHECK:STDOUT: fn() {
  105. // CHECK:STDOUT: !entry:
  106. // CHECK:STDOUT: %T.ref: %I.type = name_ref T, %T.loc8_8.1 [symbolic = %T.loc8_8.2 (constants.%T)]
  107. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.%assoc0 [concrete = constants.%assoc0]
  108. // CHECK:STDOUT: %T.as_type.loc13_4.1: type = facet_access_type %T.ref [symbolic = %T.as_type.loc13_4.2 (constants.%T.as_type)]
  109. // CHECK:STDOUT: %.loc13_4.1: type = converted %T.ref, %T.as_type.loc13_4.1 [symbolic = %T.as_type.loc13_4.2 (constants.%T.as_type)]
  110. // CHECK:STDOUT: %impl.elem0.loc13_4.1: @Use.%.loc13_4.2 (%.ee1) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_4.2 (constants.%impl.elem0)]
  111. // CHECK:STDOUT: return
  112. // CHECK:STDOUT: }
  113. // CHECK:STDOUT: }
  114. // CHECK:STDOUT:
  115. // CHECK:STDOUT: specific @F(constants.%Self) {
  116. // CHECK:STDOUT: %Self => constants.%Self
  117. // CHECK:STDOUT: %Self.as_type.loc5_14.1 => constants.%Self.as_type
  118. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.6de
  119. // CHECK:STDOUT: }
  120. // CHECK:STDOUT:
  121. // CHECK:STDOUT: specific @Use(constants.%T) {
  122. // CHECK:STDOUT: %T.loc8_8.2 => constants.%T
  123. // CHECK:STDOUT: }
  124. // CHECK:STDOUT: