aggregate_through_access.carbon 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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/full.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/aggregate_through_access.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/aggregate_through_access.carbon
  12. // --- fail_todo_tuple_access_through_witness.carbon
  13. library "[[@TEST_NAME]]";
  14. interface Z {
  15. let X:! type;
  16. }
  17. // 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]
  18. // CHECK:STDERR: fn F(T:! Z where .X = ({}, )) -> T.X.0 {
  19. // CHECK:STDERR: ^~~~~
  20. // CHECK:STDERR:
  21. fn F(T:! Z where .X = ({}, )) -> T.X.0 {
  22. return {};
  23. }
  24. // --- fail_todo_struct_access_through_witness.carbon
  25. library "[[@TEST_NAME]]";
  26. interface Z {
  27. let X:! type;
  28. }
  29. // CHECK:STDERR: fail_todo_struct_access_through_witness.carbon:[[@LINE+4]]:36: error: type `type` does not support qualified expressions [QualifiedExprUnsupported]
  30. // CHECK:STDERR: fn F(T:! Z where .X = {.t: ()}) -> T.X.t {
  31. // CHECK:STDERR: ^~~~~
  32. // CHECK:STDERR:
  33. fn F(T:! Z where .X = {.t: ()}) -> T.X.t {
  34. return ();
  35. }
  36. // --- fail_todo_array_access_through_witness.carbon
  37. library "[[@TEST_NAME]]";
  38. interface Z {
  39. let X:! type;
  40. }
  41. // CHECK:STDERR: fail_todo_array_access_through_witness.carbon:[[@LINE+4]]:40: error: cannot access member of interface `Core.IndexWith(Core.IntLiteral)` in type `type` that does not implement that interface [MissingImplInMemberAccess]
  42. // CHECK:STDERR: fn F(T:! Z where .X = array({}, 1)) -> T.X[0] {
  43. // CHECK:STDERR: ^~~~~~
  44. // CHECK:STDERR:
  45. fn F(T:! Z where .X = array({}, 1)) -> T.X[0] {
  46. return {};
  47. }
  48. // --- impl_access_through_witness.carbon
  49. library "[[@TEST_NAME]]";
  50. interface Z {
  51. let X1:! type;
  52. }
  53. interface Y {
  54. let X2:! type;
  55. }
  56. class C;
  57. impl C as Y where .X2 = {} {}
  58. fn F(T:! Z where .X1 = C) -> T.X1.(Y.X2) {
  59. return {};
  60. }