rewrite_interface_params.carbon 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 HasTypes {
  8. let A:! type;
  9. let B:! type;
  10. let C:! type;
  11. let D:! type;
  12. let E:! type;
  13. let F:! type;
  14. }
  15. interface HasParams(A:! type, B:! type, C:! type, D:! type) {
  16. let V:! HasTypes;
  17. }
  18. // Here we discover that there is a rewrite for `HasParams(...).V` only after
  19. // substitution converts each one to `HasParam(X, X, X, X).V`.
  20. fn F[X:! (HasTypes & HasParams(.Self, .Self, .Self, .Self)) where
  21. .Self impls HasParams(.A, .A, .A, .A) and
  22. .Self impls HasParams(.B, .B, .B, .B) and
  23. .Self impls HasParams(.C, .C, .C, .C) and
  24. .Self impls HasParams(.D, .D, .D, .D) and
  25. .Self impls HasParams(.E, .E, .E, .E) and
  26. .F = .Self.(HasParams(.E, .E, .E, .E).V).A and
  27. .E = .Self.(HasParams(.D, .D, .D, .D).V).A and
  28. .D = .Self.(HasParams(.C, .C, .C, .C).V).A and
  29. .C = .Self.(HasParams(.B, .B, .B, .B).V).A and
  30. .B = .Self.(HasParams(.A, .A, .A, .A).V).A and
  31. .A = .Self and .V = .Self](x: X) -> X.F { return x; }
  32. impl i32 as HasTypes
  33. where .A = .B and .B = .C and .C = .D and .D = .E and .E = .F and .F = i32 {}
  34. impl i32 as HasParams(i32, i32, i32, i32) where .V = i32 {}
  35. fn Main() -> i32 {
  36. return F(0);
  37. }
  38. // CHECK:STDOUT: result: 0