Bug 20492 – __traits(getOverloads) and covariant return types in interfaces

Status
NEW
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-01-09T02:03:57Z
Last change time
2024-12-13T19:06:44Z
Assigned to
No Owner
Creator
Adam D. Ruppe
Moved to GitHub: dmd#19656 →

Comments

Comment #0 by destructionator — 2020-01-09T02:03:57Z
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
Comment #1 by robert.schadek — 2024-12-13T19:06:44Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19656 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB