convert_args.carbon 769 B

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