// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// AUTOUPDATE
// CHECK:STDOUT: 1: 1
// CHECK:STDOUT: 2: 2
// CHECK:STDOUT: 3: 3
// CHECK:STDOUT: 4: 4
// CHECK:STDOUT: result: 0

package ExplorerTest;

class A {
  var n: i32;
  impl as ImplicitAs(i32) {
    fn Convert[self: Self]() -> i32 { return self.n; }
  }
}
impl i32 as ImplicitAs(A) {
  fn Convert[self: Self]() -> A { return {.n = self}; }
}

fn Main() -> i32 {
  var arr1: array(i32, 2) = (1, 2 as A);
  Print("1: {0}", arr1[0]);
  Print("2: {0}", arr1[1]);

  var arr2: array(A, 2) = (3, 4 as A);
  Print("3: {0}", arr2[0].n);
  Print("4: {0}", arr2[1].n);
  return 0;
}
