fail_generic_method.carbon 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637
  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/convert.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/class/fail_generic_method.carbon
  10. // TIP: To dump output, run:
  11. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/check/testdata/class/fail_generic_method.carbon
  12. class I {}
  13. class Class(T:! type) {
  14. var a: T;
  15. fn F[self: Self](n: T);
  16. }
  17. // TODO: The follow-on errors here aren't great. Investigate whether we can
  18. // enter the scope anyway if the parameters don't match.
  19. // CHECK:STDERR: fail_generic_method.carbon:[[@LINE+15]]:10: error: type `<pattern for I>` of parameter 1 in redeclaration differs from previous parameter type `<pattern for type>` [RedeclParamDiffersType]
  20. // CHECK:STDERR: fn Class(N:! I).F[self: Self](n: T) {}
  21. // CHECK:STDERR: ^
  22. // CHECK:STDERR: fail_generic_method.carbon:[[@LINE-10]]:13: note: previous declaration's corresponding parameter here [RedeclParamPrevious]
  23. // CHECK:STDERR: class Class(T:! type) {
  24. // CHECK:STDERR: ^
  25. // CHECK:STDERR:
  26. // CHECK:STDERR: fail_generic_method.carbon:[[@LINE+8]]:25: error: name `Self` not found [NameNotFound]
  27. // CHECK:STDERR: fn Class(N:! I).F[self: Self](n: T) {}
  28. // CHECK:STDERR: ^~~~
  29. // CHECK:STDERR:
  30. // CHECK:STDERR: fail_generic_method.carbon:[[@LINE+4]]:34: error: name `T` not found [NameNotFound]
  31. // CHECK:STDERR: fn Class(N:! I).F[self: Self](n: T) {}
  32. // CHECK:STDERR: ^
  33. // CHECK:STDERR:
  34. fn Class(N:! I).F[self: Self](n: T) {}