Mandeep Singh Brar <mand...@brars.co.in> wrote:

Hi,

I am not able to assign an interface to object. The following code
does not compile.

module testObj;

public interface testInterface {
        void someMethod();
}
public class testObj
{
        Object someCaller;
        this(Object caller) {
                someCaller = caller;
        }
        this(testInterface tI, bool xyz) {
                someCaller = tI;
        }
}

Shouldn't this work?

Nope. D allows interfaces to be special in certain cases (notably COM,
though other may be added in the future), and this precludes making
interfaces implicitly castable to Object.

--
Simen

Reply via email to