qualified_param_member.carbon 570 B

1234567891011121314151617181920212223242526
  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 F[T:! A](v: T, w: T) -> T {
  17. return v.(T.F)(w);
  18. }
  19. fn Main() -> i32 {
  20. var v: X = {.n = 1};
  21. var w: X = {.n = 2};
  22. return F(v, w).n;
  23. }
  24. // CHECK:STDOUT: result: 3