require_satisified.carbon 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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/require_satisified.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/require_satisified.carbon
  12. // --- todo_fail_missing_require_for_concrete_type.carbon
  13. library "[[@TEST_NAME]]";
  14. interface Z {}
  15. interface Y {
  16. extend require impls Z;
  17. }
  18. // () does not need to impl Z yet.
  19. impl () as Y;
  20. // TODO: This should be an error. () needs to impl Z at the start of the
  21. // definition.
  22. impl () as Y {}
  23. // --- todo_fail_missing_require_for_symbolic_type.carbon
  24. library "[[@TEST_NAME]]";
  25. interface Z {}
  26. interface Y {
  27. extend require impls Z;
  28. }
  29. // T does not need to impl Z yet.
  30. impl forall [T:! type] T as Y;
  31. // TODO: This should be an error. T needs to impl Z at the start of the
  32. // definition.
  33. impl forall [T:! type] T as Y {}
  34. // --- require_for_concrete_type.carbon
  35. library "[[@TEST_NAME]]";
  36. interface Z {}
  37. interface Y {
  38. extend require impls Z;
  39. }
  40. // () does not need to impl Z yet.
  41. impl () as Y;
  42. // Now we know () impls Z.
  43. impl () as Z;
  44. // So no error here.
  45. impl () as Y {}
  46. impl () as Z {}
  47. // --- require_for_symbolic_type.carbon
  48. library "[[@TEST_NAME]]";
  49. interface Z {}
  50. interface Y {
  51. extend require impls Z;
  52. }
  53. // T does not need to impl Z yet.
  54. impl forall [T:! type] T as Y;
  55. // Now we know T impls Z.
  56. impl forall [T:! type] T as Z;
  57. // So no error here.
  58. impl forall [T:! type] T as Y {}
  59. impl forall [T:! type] T as Z {}
  60. // --- require_for_symbolic_type_impl_matches_same_interface.carbon
  61. library "[[@TEST_NAME]]";
  62. interface Z {}
  63. interface Y {
  64. extend require impls Z;
  65. }
  66. // This only matches T that impl Z so no error here.
  67. impl forall [T:! Z] T as Y {}