self_recurse_with_match.carbon 574 B

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