impl_where_redecl.carbon 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. // EXTRA-ARGS: --no-dump-sem-ir
  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/impl/no_prelude/impl_where_redecl.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/impl/no_prelude/impl_where_redecl.carbon
  12. // --- match.carbon
  13. library "[[@TEST_NAME]]";
  14. interface J {}
  15. // `impl` matching ignores the `where` clause. It should not get confused by
  16. // nested `where`, so the following should not trigger impl declaration without
  17. // definition diagnostics.
  18. impl () as J;
  19. impl () as J where .Self impls type and .Self impls (type where .Self impls type) {}
  20. impl {} as J where .Self impls type and .Self impls (type where .Self impls type);
  21. impl {} as J {}
  22. // --- parens_other_nesting.carbon
  23. library "[[@TEST_NAME]]";
  24. interface K {}
  25. // `impl` matching only ignores a root-level `where` clause.
  26. impl {} as (K where .Self impls type) where .Self impls type;
  27. impl {} as (K where .Self impls type) {}
  28. // --- fail_other_nesting.carbon
  29. library "[[@TEST_NAME]]";
  30. interface L {}
  31. // CHECK:STDERR: fail_other_nesting.carbon:[[@LINE+3]]:1: error: impl declared but not defined [MissingImplDefinition]
  32. // CHECK:STDERR: impl () as (L where .Self impls type) where .Self impls type;
  33. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  34. impl () as (L where .Self impls type) where .Self impls type;
  35. impl () as L {}