January 09, 2020 [Issue 20492] New: __traits(getOverloads) and covariant return types in interfaces | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=20492 Issue ID: 20492 Summary: __traits(getOverloads) and covariant return types in interfaces Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: regression Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: destructionator@gmail.com Easier to explain with code: --- interface A { A foo(); } interface B : A { B foo(); } class C : B { C foo() { return this; } } void main() { static foreach(overload; __traits(getOverloads, B, "foo")) pragma(msg, typeof(overload)); } --- * * * Up to 2.080.1: Success with output: B() Since 2.081.2: Success with output: ----- B() A() ----- You can see there that getOverloads is considering both interface methods to be overloaded on each other, despite the fact that they have identical arguments (in this case, none). The class, C, shows that the language proper considers them to have just one slot. But getOverloads is returning both. I contend getOverloads should only return the most derived version. It did that prior to 2.80.1, so I'm calling this a regression. It is also blocking the currently most promising approach for my auto-gen java bindings. I suspect this was introduced in this PR https://github.com/dlang/dmd/pull/7959 -- |
Copyright © 1999-2021 by the D Language Foundation