impl_where_redecl.carbon 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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/impl/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/impl_where_redecl.carbon
  12. // `impl` declarations only match when they are the same syntactically.
  13. // --- fail_match_with_associated_type.carbon
  14. library "[[@TEST_NAME]]";
  15. interface I { let T:! type; }
  16. // CHECK:STDERR: fail_match_with_associated_type.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  17. // CHECK:STDERR: impl () as I where .T = {};
  18. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~
  19. // CHECK:STDERR:
  20. impl () as I where .T = {};
  21. impl () as I where .T = {} and .T impls (type where .Self impls type) {}
  22. // CHECK:STDERR: fail_match_with_associated_type.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  23. // CHECK:STDERR: impl {} as I;
  24. // CHECK:STDERR: ^~~~~~~~~~~~~
  25. // CHECK:STDERR:
  26. impl {} as I;
  27. impl {} as I where .T = {} and .T impls (type where .Self impls type) {}
  28. // CHECK:STDERR: fail_match_with_associated_type.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  29. // CHECK:STDERR: impl ({},) as I where .T = {} and .T impls (type where .Self impls type);
  30. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  31. // CHECK:STDERR:
  32. impl ({},) as I where .T = {} and .T impls (type where .Self impls type);
  33. impl ({},) as I where .T = {} {}
  34. // --- fail_match_with_empty_interface.carbon
  35. library "[[@TEST_NAME]]";
  36. interface J {}
  37. // CHECK:STDERR: fail_match_with_empty_interface.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  38. // CHECK:STDERR: impl () as J;
  39. // CHECK:STDERR: ^~~~~~~~~~~~~
  40. // CHECK:STDERR:
  41. impl () as J;
  42. impl () as J where .Self impls type and .Self impls (type where .Self impls type) {}
  43. // CHECK:STDERR: fail_match_with_empty_interface.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  44. // CHECK:STDERR: impl {} as J where .Self impls type and .Self impls (type where .Self impls type);
  45. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. // CHECK:STDERR:
  47. impl {} as J where .Self impls type and .Self impls (type where .Self impls type);
  48. impl {} as J {}
  49. // --- fail_parens_other_nesting.carbon
  50. library "[[@TEST_NAME]]";
  51. interface K {}
  52. // CHECK:STDERR: fail_parens_other_nesting.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  53. // CHECK:STDERR: impl {} as (K where .Self impls type) where .Self impls type;
  54. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  55. // CHECK:STDERR:
  56. impl {} as (K where .Self impls type) where .Self impls type;
  57. impl {} as (K where .Self impls type) {}
  58. // --- fail_other_nesting.carbon
  59. library "[[@TEST_NAME]]";
  60. interface L {}
  61. // CHECK:STDERR: fail_other_nesting.carbon:[[@LINE+4]]:1: error: impl declared but not defined [ImplMissingDefinition]
  62. // CHECK:STDERR: impl () as (L where .Self impls type) where .Self impls type;
  63. // CHECK:STDERR: ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. // CHECK:STDERR:
  65. impl () as (L where .Self impls type) where .Self impls type;
  66. impl () as L {}