self_recurse_with_match_first.carbon 586 B

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