Best error msg ever

Chris Wright via Digitalmars-d digitalmars-d at puremagic.com
Mon Feb 13 16:04:45 PST 2017


On Mon, 13 Feb 2017 15:09:31 +0000, Kagamin wrote:

> On Monday, 13 February 2017 at 14:46:38 UTC, Mike Parker wrote:
>> "References cannot be upcast to the enclosing class object, nor can
>> they be downcast to a derived interface."
>>
>> https://dlang.org/spec/interface.html#com-interfaces
> 
> COM interfaces can't be downcasted indeed, but it should be possible for
> D interfaces.

But the case that I brought up was cross-casting.

I have an object. It's a D object, which the compiler knows. I don't know 
if it implements a specific interface, so I cast it. That gives me an 
expression of the interface type that either refers to the same object or 
is null.

Except it isn't @safe for some unknown reason.


More information about the Digitalmars-d mailing list