build_tree.carbon 747 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. // CHECK:STDOUT: result: 0
  7. package ExplorerTest api;
  8. class S(T:! type) {}
  9. class Z {}
  10. class Tree(L:! type, R:! type) {}
  11. class Leaf {}
  12. interface Foo(T:! type) {}
  13. impl forall [U:! type, T:! Foo(Tree(U, U))] S(T) as Foo(U) {}
  14. alias Level1 = Tree(Leaf, Leaf);
  15. alias Level2 = Tree(Level1, Level1);
  16. alias Level3 = Tree(Level2, Level2);
  17. alias Level4 = Tree(Level3, Level3);
  18. alias Level5 = Tree(Level4, Level4);
  19. impl Z as Foo(Level5) {}
  20. fn F[T:! Foo(Leaf)](x: T) {}
  21. fn Main() -> i32 {
  22. var n: S(S(S(S(S(Z))))) = {};
  23. F(n);
  24. return 0;
  25. }