mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 22:02:23 +01:00
Add a blanket `ImplicitAs` implementation to perform the conversions that explorer can perform as built-in conversions. This allows those conversions to be detected by constraints and to be used as part of other user-defined conversions. For now, a single monolithic conversion is exposed. I intend to split this up into multiple smaller conversion kinds for each kind of conversion in a follow-up change. Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
35 lines
694 B
Plaintext
35 lines
694 B
Plaintext
// 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
|
|
// RUN: %{explorer-run}
|
|
// RUN: %{explorer-run-trace}
|
|
// CHECK:STDOUT: 1
|
|
// CHECK:STDOUT: 2
|
|
// CHECK:STDOUT: 3
|
|
// CHECK:STDOUT: result: 0
|
|
|
|
package ExplorerTest api;
|
|
|
|
base class A {
|
|
var a: i32;
|
|
}
|
|
|
|
base class B extends A {
|
|
var b: i32;
|
|
}
|
|
|
|
class C extends B {
|
|
var c: i32;
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
var c: C = {.base = {.base = {.a = 1}, .b = 2}, .c = 3};
|
|
let (pa: A*, pb: B*, pc: C*) = (&c, &c, &c);
|
|
Print("{0}", pa->a);
|
|
Print("{0}", pb->b);
|
|
Print("{0}", pc->c);
|
|
return 0;
|
|
}
|