In the following code `alias this` should not be used since there is method `Boo.opBinary` that takes argument of type `Foo` explicitly.
----------------------------------------
import std.stdio;
struct Foo
{
int v;
auto opBinaryRight(string op)(int lhs) if (op == "*")
{
writeln("int * Foo");
return Boo(lhs * v);
}
}
struct Boo
{
int v;
alias v this;
auto opBinary(string op)(Foo rhs) if (op == "*")
{
writeln("Boo * Foo");
return Boo(v * rhs.v);
}
}
void main(string[] args)
{
Boo(1) * Foo(2);
}
----------------------------------------
The output should be "Boo * Foo" regardless whether there is `alias this` or not.
However it is "int * Foo" with `alias this` line and "Boo * Foo" without it.
Tested with DMD v2.067.0
Comment #1 by dlang-bugzilla — 2015-04-05T03:59:06Z