impls_constraint.carbon 700 B

1234567891011121314151617181920212223242526272829303132333435
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. interface A {
  8. fn F() -> i32;
  9. }
  10. interface B {
  11. fn F() -> i32;
  12. fn G() -> i32;
  13. }
  14. interface C(T:! type) {
  15. fn H() -> T;
  16. }
  17. impl i32 as A {
  18. fn F() -> i32 { return 1; }
  19. }
  20. impl i32 as B & C(i32) where .Self impls A {
  21. fn F() -> i32 { return 2; }
  22. fn G() -> i32 { return 3; }
  23. fn H() -> i32 { return 4; }
  24. }
  25. fn Main() -> i32 {
  26. let n: i32 = 0;
  27. return n.(A.F)() * 1000 + n.(B.F)() * 100 + n.(B.G)() * 10 + n.(C(i32).H)();
  28. }
  29. // CHECK:STDOUT: result: 1234