Closed
Description
Thise code fails with The result of this operation (Int) is not compatible with declared return type Foo
abstract Foo(Int) {
public function new(x:Int) this = x;
@:op(A+B) public static function add(a:Foo, b:Foo):Foo;
}
class Main {
public static function main() {
var f:Foo = new Foo(1);
f+f;
}
}
Adding from Int
to the abstract allows the unification with the return type. However, I may not want to allow that unification in general. This forces me to painfully supply bodies for all of the operators, e.g. return new Foo((cast a) + (cast b))
.
It'd be nice if the compiler allowed the unification between the abstract type and underlying type in the case of bodyless operators.
Metadata
Metadata
Assignees
Labels
No labels
Activity