self_recurse_with_match_first.carbon 639 B

1234567891011121314151617181920212223242526
  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. __match_first {
  12. impl forall [T:! type where .Self == i32*] T as Foo {}
  13. impl forall [T:! type where .Self* impls Foo] T as Foo {}
  14. }
  15. fn F[T:! Foo](x: T) {}
  16. fn Main() -> i32 {
  17. // This is OK: we don't recursively consider the second `impl`, because the
  18. // first one matches.
  19. F(0);
  20. return 0;
  21. }