convert.carbon 431 B

1234567891011121314151617181920
  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. // NOAUTOUPDATE
  6. package ExplorerTest api;
  7. class A { var n: i32; }
  8. impl A as As(i32) {
  9. fn Convert[self: Self]() -> i32 { return self.n; }
  10. }
  11. fn Main() -> i32 {
  12. var a: A = {.n = 5};
  13. return a as i32;
  14. }
  15. // CHECK:STDOUT: result: 5