where_impls.carbon 548 B

12345678910111213141516171819202122232425262728293031
  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: i32.F
  7. // CHECK:STDOUT: result: 0
  8. package ExplorerTest api;
  9. interface Base {
  10. fn F();
  11. }
  12. interface Extension {
  13. extends Base;
  14. }
  15. fn F[T:! type where .Self impls Extension](x: T) {
  16. x.(Extension.F)();
  17. }
  18. impl i32 as Extension {
  19. fn F() { Print("i32.F"); }
  20. }
  21. fn Main() -> i32 {
  22. var n: i32 = 0;
  23. F(n);
  24. return 0;
  25. }