qualified_constraint_member.carbon 855 B

123456789101112131415161718192021222324252627282930313233
  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. // RUN: %{explorer} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{explorer} %s
  10. // CHECK: result: 12
  11. package Foo api;
  12. interface A {
  13. fn F[me: Self]() -> i32;
  14. }
  15. interface B {
  16. fn G(o: Self) -> i32;
  17. }
  18. alias C = A & B;
  19. class X {
  20. impl as A {
  21. fn F[me: Self]() -> i32 { return 10 * me.n; }
  22. }
  23. impl as B {
  24. fn G(o: Self) -> i32 { return o.n; }
  25. }
  26. var n: i32;
  27. }
  28. fn Main() -> i32 {
  29. var v: X = {.n = 1};
  30. var w: X = {.n = 2};
  31. return v.(C.F)() + X.(C.G)(w);
  32. }