where_impls.carbon 550 B

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