convert_args.carbon 815 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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: 123
  9. package ExplorerTest api;
  10. class One {
  11. impl One as ImplicitAs(i32) {
  12. fn Convert[me: Self]() -> i32 { return 1; }
  13. }
  14. }
  15. class Two {
  16. impl Two as ImplicitAs(i32) {
  17. fn Convert[me: Self]() -> i32 { return 2; }
  18. }
  19. }
  20. class N {
  21. impl N as ImplicitAs(i32) {
  22. fn Convert[me: Self]() -> i32 { return me.n; }
  23. }
  24. var n: i32;
  25. }
  26. fn Get(a: i32, b: i32, c: i32) -> i32 {
  27. return 100 * a + 10 * b + c;
  28. }
  29. fn Main() -> i32 {
  30. var i: One = {};
  31. var ii: Two = {};
  32. var iii: N = {.n = 3};
  33. return Get(i, ii, iii);
  34. }