convert_rhs.carbon 445 B

123456789101112131415161718192021
  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: 1
  7. package ExplorerTest api;
  8. class A {
  9. var n: i32;
  10. }
  11. impl i32 as ImplicitAs(A) {
  12. fn Convert[self: Self]() -> A { return {.n = self }; }
  13. }
  14. fn Main() -> i32 {
  15. var a: A = {.n = 0};
  16. a = 1;
  17. return a.n;
  18. }