qualified_interface_member.carbon 519 B

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