implicit_conversion.carbon 428 B

12345678910111213141516171819202122
  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. var n: i32;
  9. }
  10. impl i32 as ImplicitAs(A) {
  11. fn Convert[self: Self]() -> A { return {.n = self}; }
  12. }
  13. var a: A = 5;
  14. fn Main() -> i32 {
  15. return a.n;
  16. }
  17. // CHECK:STDOUT: result: 5