build_tree.carbon 748 B

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