convert_args.carbon 1008 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. // RUN: %{explorer} %s 2>&1 | \
  6. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes=false %s
  7. // RUN: %{explorer} --parser_debug --trace_file=- %s 2>&1 | \
  8. // RUN: %{FileCheck} --match-full-lines --allow-unused-prefixes %s
  9. // AUTOUPDATE: %{explorer} %s
  10. // CHECK: result: 123
  11. package ExplorerTest api;
  12. class One {
  13. impl One as ImplicitAs(i32) {
  14. fn Convert[me: Self]() -> i32 { return 1; }
  15. }
  16. }
  17. class Two {
  18. impl Two as ImplicitAs(i32) {
  19. fn Convert[me: Self]() -> i32 { return 2; }
  20. }
  21. }
  22. class N {
  23. impl N as ImplicitAs(i32) {
  24. fn Convert[me: Self]() -> i32 { return me.n; }
  25. }
  26. var n: i32;
  27. }
  28. fn Get(a: i32, b: i32, c: i32) -> i32 {
  29. return 100 * a + 10 * b + c;
  30. }
  31. fn Main() -> i32 {
  32. var i: One = {};
  33. var ii: Two = {};
  34. var iii: N = {.n = 3};
  35. return Get(i, ii, iii);
  36. }