validate_impl_constraints.carbon 1.6 KB

123456789101112131415161718192021222324252627282930313233343536
  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/facet_types.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/validate_impl_constraints.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/facet/validate_impl_constraints.carbon
  12. // --- fail_todo_where_impls_tests_associated_constant_of_generic_type.carbon
  13. class C(U:! type) {}
  14. // C(U) impls M if U impls L.
  15. interface L {}
  16. interface M {}
  17. impl forall [U:! L] C(U) as M {}
  18. // U requires that C(.Self) impls M.
  19. // - C(.Self) impls M can be rewritten as C(U) impls M.
  20. // - C(U) impls M if U impls L => Requires U impls L.
  21. fn F(U:! type where C(.Self) impls M) {}
  22. fn G(T:! L) {
  23. // CHECK:STDERR: fail_todo_where_impls_tests_associated_constant_of_generic_type.carbon:[[@LINE+7]]:3: error: cannot convert type `T` that implements `L` into type implementing `type where...` [ConversionFailureFacetToFacet]
  24. // CHECK:STDERR: F(T);
  25. // CHECK:STDERR: ^~~~
  26. // CHECK:STDERR: fail_todo_where_impls_tests_associated_constant_of_generic_type.carbon:[[@LINE-6]]:6: note: initializing generic parameter `U` declared here [InitializingGenericParam]
  27. // CHECK:STDERR: fn F(U:! type where C(.Self) impls M) {}
  28. // CHECK:STDERR: ^
  29. // CHECK:STDERR:
  30. F(T);
  31. }