implicit_conversion_choice.carbon 445 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. choice A {
  8. Value(i32)
  9. }
  10. impl i32 as ImplicitAs(A) {
  11. fn Convert[self: Self]() -> A { return A.Value(self + 1); }
  12. }
  13. fn Main() -> i32 {
  14. let A.Value(n: i32) = 2;
  15. return n;
  16. }
  17. // CHECK:STDOUT: result: 3