https://issues.dlang.org/show_bug.cgi?id=23234
Issue ID: 23234
Summary: Delegate literal with inferred return value that
requires following alias-this uses class cast instead.
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Consider the following code:
class Bar
{
}
class Foo
{
Bar get() { return new Bar; }
alias get this;
}
void main() {
auto foo = new Foo;
void test(Bar delegate() dg) {
assert(dg() !is null);
}
test({ return foo; });
}
-vcg-ast reveals that the delegate is compiled to `return cast(Bar) foo`,
rather than `return foo.get`.
`test(delegate Bar() { return foo; })` works.
--