Implicit conversion to base interface doesn't work inside initialization of AA of objects

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 17 09:54:57 PDT 2014


Reduced:

interface IBase {}
class Impl(T): IBase {
     T value;
}
void main() {
     IBase a = true ? (new Impl!uint) : (new Impl!string);
}



test.d(6,23): Error: cannot implicitly convert expression (new 
Impl!uint) of type object.Object to test.IBase

Bye,
bearophile


More information about the Digitalmars-d mailing list