pass_equal_to_rewrite.carbon 758 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. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: result: 1
  9. package ExplorerTest api;
  10. interface Container {
  11. let Element:! type;
  12. fn Front[self: Self]() -> Element;
  13. }
  14. fn A[T:! Container where .Element = i32](x: T) -> T.Element {
  15. return x.Front();
  16. }
  17. fn B[T:! Container where .Element == i32](x: T) -> T.Element {
  18. return A(x);
  19. }
  20. external impl (i32, i32) as Container where .Element = i32 {
  21. fn Front[self: Self]() -> i32 {
  22. let (a: i32, b: i32) = self;
  23. return a;
  24. }
  25. }
  26. fn Main() -> i32 {
  27. return B((1, 2));
  28. }