On Sunday, 18 June 2023 at 16:58:15 UTC, Ali Çehreli wrote:
The problem is with the deduced type of 'services'. I don't know the mechanism behind it but the common type of 'truck' and 'ship' are deduced to be Object. Apparently, their interfaces don't take part in that decision. I don't know why.
This is very interesting because it looks like a bug. Why is there no problem in an abstracted object, but things get confused in the interface (ITransport)?
On Sunday, 18 June 2023 at 16:58:15 UTC, Ali Çehreli wrote:
One solution is to help the compiler by casting them to your desired interface:
In fact, there is no need to cast: ```d interface ITransport { string deliver(); } //... void main() { auto truck = new Truck; ITransport ship = new Ship; /* or ITransport truck = new Truck; auto ship = new Ship; // or ITransport truck = new Truck; ITransport ship = new Ship;//*/ } ``` SDB@78