mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-28 13:10:12 +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
462 B
Plaintext
20 lines
462 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: 3
|
|
|
|
package Foo api;
|
|
|
|
class X {
|
|
fn F[self: Self](o: Self) -> Self { return {.n = self.n + o.n}; }
|
|
var n: i32;
|
|
}
|
|
|
|
fn Main() -> i32 {
|
|
return {.n = 1}.(X.F)({.n = 2}).n;
|
|
}
|