self_recurse_with_match.carbon 627 B

123456789101112131415161718192021222324
  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: result: 0
  9. package ExplorerTest api;
  10. interface Foo {}
  11. impl i32* as Foo {}
  12. impl forall [T:! type where .Self* impls Foo] T as Foo {}
  13. fn F[T:! Foo](x: T) {}
  14. fn Main() -> i32 {
  15. // This is OK: we don't consider the second impl when recursively checking
  16. // for `impl i32* as Foo` because the first impl is a better match.
  17. F(0);
  18. return 0;
  19. }