pass_rewrite_to_equal.carbon 696 B

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