qualified_interface_member.carbon 511 B

12345678910111213141516171819202122
  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 Main() -> i32 {
  18. var v: X = {.n = 1};
  19. var w: X = {.n = 2};
  20. return v.(A.F)(w).n;
  21. }