convert_args.carbon 781 B

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