dmd
dmd copied to clipboard
Enhancement: `Base(child)` class object upcast
FundamentalType(arg)
works, e.g. int(2)
.
Enum(Enum.foo)
works, which does nothing - see compilable/b16346.d
below and/or https://issues.dlang.org/show_bug.cgi?id=16346.
Let's allow class instance upcasting without having to use cast
- Base(child)
. cast
can be bug-prone, and upcasting is always fine. In generic code it's not always clear what a type resolves to, so avoiding cast
makes code reviews easier.
Here upcasting takes precedence over a static opCall, but that could be swapped.