param_qualified_interface_member.carbon 566 B

12345678910111213141516171819202122232425
  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. // CHECK:STDOUT: result: 3
  7. package Foo api;
  8. interface A {
  9. fn F[self: Self](o: Self) -> Self;
  10. }
  11. class X {
  12. impl as A {
  13. fn F[self: Self](o: Self) -> Self { return {.n = self.n + o.n}; }
  14. }
  15. var n: i32;
  16. }
  17. fn F[T:! A](v: T, w: T) -> T {
  18. return v.(T.(A.F))(w);
  19. }
  20. fn Main() -> i32 {
  21. var v: X = {.n = 1};
  22. var w: X = {.n = 2};
  23. return F(v, w).n;
  24. }