mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-27 18:40:10 +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>
20 lines
447 B
Plaintext
20 lines
447 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: result: 5
|
|
|
|
package ExplorerTest api;
|
|
|
|
class A {
|
|
var n: i32;
|
|
fn Get[self: Self]() -> i32 { return self.n; }
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
return ({.n = 5} as A).Get();
|
|
}
|