build_tree.carbon 801 B

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