where_is.carbon 599 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. // AUTOUPDATE
  6. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: i32.F
  9. // CHECK:STDOUT: result: 0
  10. package ExplorerTest api;
  11. interface Base {
  12. fn F();
  13. }
  14. interface Extension {
  15. extends Base;
  16. }
  17. fn F[T:! Type where .Self is Extension](x: T) {
  18. x.(Extension.F)();
  19. }
  20. impl i32 as Extension {
  21. fn F() { Print("i32.F"); }
  22. }
  23. fn Main() -> i32 {
  24. var n: i32 = 0;
  25. F(n);
  26. return 0;
  27. }