aggregate_through_access.carbon 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/check/testdata/facet/aggregate_through_access.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/aggregate_through_access.carbon
  10. // --- fail_todo_tuple_access_through_witness.carbon
  11. library "[[@TEST_NAME]]";
  12. interface Z {
  13. let X:! type;
  14. }
  15. // CHECK:STDERR: fail_todo_tuple_access_through_witness.carbon:[[@LINE+4]]:34: error: type `type` does not support tuple indexing; only tuples can be indexed that way [TupleIndexOnANonTupleType]
  16. // CHECK:STDERR: fn F(T:! Z where .X = ({}, )) -> T.X.0 {
  17. // CHECK:STDERR: ^~~~~
  18. // CHECK:STDERR:
  19. fn F(T:! Z where .X = ({}, )) -> T.X.0 {
  20. return {};
  21. }
  22. // --- fail_todo_struct_access_through_witness.carbon
  23. library "[[@TEST_NAME]]";
  24. interface Z {
  25. let X:! type;
  26. }
  27. // CHECK:STDERR: fail_todo_struct_access_through_witness.carbon:[[@LINE+4]]:36: error: type `type` does not support qualified expressions [QualifiedExprUnsupported]
  28. // CHECK:STDERR: fn F(T:! Z where .X = {.t: ()}) -> T.X.t {
  29. // CHECK:STDERR: ^~~~~
  30. // CHECK:STDERR:
  31. fn F(T:! Z where .X = {.t: ()}) -> T.X.t {
  32. return ();
  33. }
  34. // --- fail_todo_array_access_through_witness.carbon
  35. library "[[@TEST_NAME]]";
  36. interface Z {
  37. let X:! type;
  38. }
  39. // CHECK:STDERR: fail_todo_array_access_through_witness.carbon:[[@LINE+4]]:40: error: type `type` does not support indexing [TypeNotIndexable]
  40. // CHECK:STDERR: fn F(T:! Z where .X = array({}, 1)) -> T.X[0] {
  41. // CHECK:STDERR: ^~~~~~
  42. // CHECK:STDERR:
  43. fn F(T:! Z where .X = array({}, 1)) -> T.X[0] {
  44. return {};
  45. }
  46. // --- impl_access_through_witness.carbon
  47. library "[[@TEST_NAME]]";
  48. interface Z {
  49. let X1:! type;
  50. }
  51. interface Y {
  52. let X2:! type;
  53. }
  54. class C;
  55. impl C as Y where .X2 = {} {}
  56. fn F(T:! Z where .X1 = C) -> T.X1.(Y.X2) {
  57. return {};
  58. }