fail_assoc_fn_invalid_use.carbon 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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>` 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 = symbolic_binding Self, 0 [symbolic]
  31. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic]
  32. // CHECK:STDOUT: %pattern_type.89c: type = pattern_type %Self.binding.as_type [symbolic]
  33. // CHECK:STDOUT: %I.F.type: type = fn_type @I.F [concrete]
  34. // CHECK:STDOUT: %I.F: %I.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.%I.F.decl [concrete]
  37. // CHECK:STDOUT: %type: type = facet_type <type> [concrete]
  38. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self]
  39. // CHECK:STDOUT: %T: %I.type = symbolic_binding T, 0 [symbolic]
  40. // CHECK:STDOUT: %pattern_type.09a: type = pattern_type %I.type [concrete]
  41. // CHECK:STDOUT: %Use.type: type = fn_type @Use [concrete]
  42. // CHECK:STDOUT: %Use: %Use.type = struct_value () [concrete]
  43. // CHECK:STDOUT: %T.binding.as_type: type = symbolic_binding_type T, 0, %T [symbolic]
  44. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T, @I [symbolic]
  45. // CHECK:STDOUT: %.258: type = fn_type_with_self_type %I.F.type, %T [symbolic]
  46. // CHECK:STDOUT: %impl.elem0: %.258 = impl_witness_access %I.lookup_impl_witness, element0 [symbolic]
  47. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %.258 [symbolic]
  48. // CHECK:STDOUT: }
  49. // CHECK:STDOUT:
  50. // CHECK:STDOUT: file {
  51. // CHECK:STDOUT: package: <namespace> = namespace [concrete] {
  52. // CHECK:STDOUT: .I = %I.decl
  53. // CHECK:STDOUT: .Use = %Use.decl
  54. // CHECK:STDOUT: }
  55. // CHECK:STDOUT: %I.decl: type = interface_decl @I [concrete = constants.%I.type] {} {}
  56. // CHECK:STDOUT: %Use.decl: %Use.type = fn_decl @Use [concrete = constants.%Use] {
  57. // CHECK:STDOUT: %T.patt: %pattern_type.09a = symbolic_binding_pattern T, 0 [concrete]
  58. // CHECK:STDOUT: } {
  59. // CHECK:STDOUT: %.loc8: type = splice_block %I.ref [concrete = constants.%I.type] {
  60. // CHECK:STDOUT: %.Self: %type = symbolic_binding .Self [symbolic_self = constants.%.Self]
  61. // CHECK:STDOUT: %I.ref: type = name_ref I, file.%I.decl [concrete = constants.%I.type]
  62. // CHECK:STDOUT: }
  63. // CHECK:STDOUT: %T.loc8_8.2: %I.type = symbolic_binding T, 0 [symbolic = %T.loc8_8.1 (constants.%T)]
  64. // CHECK:STDOUT: }
  65. // CHECK:STDOUT: }
  66. // CHECK:STDOUT:
  67. // CHECK:STDOUT: interface @I {
  68. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = constants.%Self]
  69. // CHECK:STDOUT: %I.F.decl: %I.F.type = fn_decl @I.F [concrete = constants.%I.F] {
  70. // CHECK:STDOUT: %self.patt: @I.F.%pattern_type (%pattern_type.89c) = value_binding_pattern self [concrete]
  71. // CHECK:STDOUT: %self.param_patt: @I.F.%pattern_type (%pattern_type.89c) = value_param_pattern %self.patt, call_param0 [concrete]
  72. // CHECK:STDOUT: } {
  73. // CHECK:STDOUT: %self.param: @I.F.%Self.binding.as_type (%Self.binding.as_type) = value_param call_param0
  74. // CHECK:STDOUT: %.loc5_14.1: type = splice_block %.loc5_14.2 [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)] {
  75. // CHECK:STDOUT: %Self.ref: %I.type = name_ref Self, @I.%Self [symbolic = %Self (constants.%Self)]
  76. // CHECK:STDOUT: %Self.as_type: type = facet_access_type %Self.ref [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  77. // CHECK:STDOUT: %.loc5_14.2: type = converted %Self.ref, %Self.as_type [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  78. // CHECK:STDOUT: }
  79. // CHECK:STDOUT: %self: @I.F.%Self.binding.as_type (%Self.binding.as_type) = value_binding self, %self.param
  80. // CHECK:STDOUT: }
  81. // CHECK:STDOUT: %assoc0: %I.assoc_type = assoc_entity element0, %I.F.decl [concrete = constants.%assoc0]
  82. // CHECK:STDOUT:
  83. // CHECK:STDOUT: !members:
  84. // CHECK:STDOUT: .Self = %Self
  85. // CHECK:STDOUT: .F = %assoc0
  86. // CHECK:STDOUT: witness = (%I.F.decl)
  87. // CHECK:STDOUT:
  88. // CHECK:STDOUT: !requires:
  89. // CHECK:STDOUT: }
  90. // CHECK:STDOUT:
  91. // CHECK:STDOUT: generic fn @I.F(@I.%Self: %I.type) {
  92. // CHECK:STDOUT: %Self: %I.type = symbolic_binding Self, 0 [symbolic = %Self (constants.%Self)]
  93. // CHECK:STDOUT: %Self.binding.as_type: type = symbolic_binding_type Self, 0, %Self [symbolic = %Self.binding.as_type (constants.%Self.binding.as_type)]
  94. // CHECK:STDOUT: %pattern_type: type = pattern_type %Self.binding.as_type [symbolic = %pattern_type (constants.%pattern_type.89c)]
  95. // CHECK:STDOUT:
  96. // CHECK:STDOUT: fn(%self.param: @I.F.%Self.binding.as_type (%Self.binding.as_type));
  97. // CHECK:STDOUT: }
  98. // CHECK:STDOUT:
  99. // CHECK:STDOUT: generic fn @Use(%T.loc8_8.2: %I.type) {
  100. // CHECK:STDOUT: %T.loc8_8.1: %I.type = symbolic_binding T, 0 [symbolic = %T.loc8_8.1 (constants.%T)]
  101. // CHECK:STDOUT:
  102. // CHECK:STDOUT: !definition:
  103. // CHECK:STDOUT: %T.binding.as_type: type = symbolic_binding_type T, 0, %T.loc8_8.1 [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  104. // CHECK:STDOUT: %I.lookup_impl_witness: <witness> = lookup_impl_witness %T.loc8_8.1, @I [symbolic = %I.lookup_impl_witness (constants.%I.lookup_impl_witness)]
  105. // CHECK:STDOUT: %.loc13_4.2: type = fn_type_with_self_type constants.%I.F.type, %T.loc8_8.1 [symbolic = %.loc13_4.2 (constants.%.258)]
  106. // CHECK:STDOUT: %impl.elem0.loc13_4.2: @Use.%.loc13_4.2 (%.258) = impl_witness_access %I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_4.2 (constants.%impl.elem0)]
  107. // CHECK:STDOUT: %require_complete: <witness> = require_complete_type %.loc13_4.2 [symbolic = %require_complete (constants.%require_complete)]
  108. // CHECK:STDOUT:
  109. // CHECK:STDOUT: fn() {
  110. // CHECK:STDOUT: !entry:
  111. // CHECK:STDOUT: %T.ref: %I.type = name_ref T, %T.loc8_8.2 [symbolic = %T.loc8_8.1 (constants.%T)]
  112. // CHECK:STDOUT: %F.ref: %I.assoc_type = name_ref F, @I.%assoc0 [concrete = constants.%assoc0]
  113. // CHECK:STDOUT: %T.as_type: type = facet_access_type %T.ref [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  114. // CHECK:STDOUT: %.loc13_4.1: type = converted %T.ref, %T.as_type [symbolic = %T.binding.as_type (constants.%T.binding.as_type)]
  115. // CHECK:STDOUT: %impl.elem0.loc13_4.1: @Use.%.loc13_4.2 (%.258) = impl_witness_access constants.%I.lookup_impl_witness, element0 [symbolic = %impl.elem0.loc13_4.2 (constants.%impl.elem0)]
  116. // CHECK:STDOUT: return
  117. // CHECK:STDOUT: }
  118. // CHECK:STDOUT: }
  119. // CHECK:STDOUT:
  120. // CHECK:STDOUT: specific @I.F(constants.%Self) {
  121. // CHECK:STDOUT: %Self => constants.%Self
  122. // CHECK:STDOUT: %Self.binding.as_type => constants.%Self.binding.as_type
  123. // CHECK:STDOUT: %pattern_type => constants.%pattern_type.89c
  124. // CHECK:STDOUT: }
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: specific @Use(constants.%T) {
  127. // CHECK:STDOUT: %T.loc8_8.1 => constants.%T
  128. // CHECK:STDOUT: }
  129. // CHECK:STDOUT: