fail_extend_with_self.carbon 641 B

12345678910111213141516171819202122232425262728
  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. // AUTOUPDATE
  6. package ExplorerTest api;
  7. interface Z {
  8. fn Zero() -> Self;
  9. }
  10. class Point {
  11. var x: i32;
  12. var y: i32;
  13. // `Self` not allowed after `extend impl`.
  14. // CHECK:STDERR: SYNTAX ERROR: fail_extend_with_self.carbon:[[@LINE+1]]: syntax error, unexpected SELF, expecting AS
  15. extend impl Self as Z {
  16. fn Zero() -> Self {
  17. return {.x = 0, .y = 0};
  18. }
  19. }
  20. }
  21. fn Main() -> i32 {
  22. var a: Point = Point.Zero();
  23. return p.x;
  24. }