Files
carbon-lang/toolchain/check/testdata/operators/overloaded/binary_op.carbon.tmpl
T
Richard Smith 344f0b7550 Support for heterogeneous operators. (#5653)
Replace the binary `Operation` interfaces with the `OperationWith(T:!
type)` interfaces described in the design, and add a `Result` associated
type for both unary and binary operations. Update the `impl`s in the
prelude for integer types to use the new form, including supporting
implicit conversion of either operand.

I've tried to split this PR up into commits focused on distinct changes
for review convenience. It may be simplest to review it one commit at a
time.
2025-06-13 01:55:24 +00:00

36 lines
725 B
Cheetah

// 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
//
// TODO: Add ranges and switch to "--dump-sem-ir-ranges=only".
// EXTRA-ARGS: --dump-sem-ir-ranges=if-present
//
// AUTOUPDATE
HEADER
package User;
class C {};
impl C as Core.INTERFACEWith(C) where .Result = C {
fn Op[self: C](other: C) -> C {
return {};
}
}
impl C as Core.INTERFACEAssignWith(C) {
fn Op[addr self: C*](other: C) {}
}
fn TestOp(a: C, b: C) -> C {
//@dump-sem-ir-begin
return a OP b;
//@dump-sem-ir-end
}
fn TestAssign(a: C*, b: C) {
//@dump-sem-ir-begin
*a OP= b;
//@dump-sem-ir-end
}