On Tuesday, 21 May 2019 at 07:59:13 UTC, Jim wrote:
On Tuesday, 21 May 2019 at 07:33:17 UTC, rumbu wrote:
On Tuesday, 21 May 2019 at 07:16:49 UTC, Jim wrote:
On Tuesday, 21 May 2019 at 07:04:27 UTC, rumbu wrote:
On Tuesday, 21 May 2019 at 05:51:30 UTC, Jim wrote:

That's because foo is of type Base, not implementing FeatureX.

Right, Base isn't implementing FeatureX, but foo is really a Foo

That's your knowledge, for the compiler foo is really a Base, as written in your own code.


Yes, thinking about it again it makes sense.

It doesn't even slightly make sense. I just ran into this today myself. Unlike Java and C#, casting from Foo to FeatureX is not an assertion that the Foo implements FeatureX. Instead it's how you test at runtime if the class of a specific object derived from Foo implements FeatureX: if it doesn't then the result of the cast is null. I've opened a bug report at https://issues.dlang.org/show_bug.cgi?id=20000.

Reply via email to