Casting to interface not allowed in @safe code?
    Jim 
    jimwoo21680 at hotmail.com
       
    Tue May 21 05:51:30 UTC 2019
    
    
  
Hi,
consider this:
interface Base
{
   void setup();
}
interface FeatureX
{
   void x();
}
class Foo: Base, FeatureX
{
   void setup(){};
   void x(){};
}
void main()
{
   Base foo = new Foo(); // This would be the result of a factory 
class
   (cast(FeatureX)foo).x(); // 1
}
1) error: casting to interface FeatureX is not allowed in @safe 
code.
Question: How to call foo.x in @safe code ?
    
    
More information about the Digitalmars-d-learn
mailing list