binary_op.carbon.tmpl 709 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. HEADER
  7. // --- prelude.carbon
  8. package Core api;
  9. interface INTERFACE {
  10. fn Op[self: Self](other: Self) -> Self;
  11. }
  12. interface INTERFACEAssign {
  13. fn Op[addr self: Self*](other: Self);
  14. }
  15. // --- user.carbon
  16. package User api;
  17. import Core;
  18. class C {};
  19. impl C as Core.INTERFACE {
  20. fn Op[self: C](other: C) -> C {
  21. return {};
  22. }
  23. }
  24. impl C as Core.INTERFACEAssign {
  25. fn Op[addr self: C*](other: C) {}
  26. }
  27. fn TestOp(a: C, b: C) -> C {
  28. return a OP b;
  29. }
  30. fn TestAssign(a: C*, b: C) {
  31. *a OP= b;
  32. }