rewrite_interface_params.carbon 1.4 KB

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