implicit_conversion.carbon 506 B

1234567891011121314151617181920212223
  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 A {
  8. extend impl as ImplicitAs(i32) {
  9. fn Convert[self: Self]() -> i32 { return self.n; }
  10. }
  11. var n: i32;
  12. }
  13. fn Main() -> i32 {
  14. let a: A = {.n = 1};
  15. let b: A = {.n = 2};
  16. let (x: i32, var y: i32) = (a, b);
  17. return x + y;
  18. }
  19. // CHECK:STDOUT: result: 3