------- Comment #11 from  2009-01-21 01:10 -------
(In reply to comment #10)
> But I can still cast to the interface.  Protection attributes are compile-time
> entities, they are not flagged at runtime:
> SoundManager s;
> Object o = s;
> INetworkListener inl = cast(INetworkListener)o;
> The compiler just looks in the object's list of interfaces to see if it finds
> that interface.  There is no protection associated with it at runtime.

So what? How does this differ from the following in C++:

class A {
    void foo();

class B : protected A {

B* b = new B();
//b->foo(); // error
//A* a = b; // error
void* o = b;
A* a = (A*)o;

You just hijacked type system, that's it.

One possible solution would be to add protection flag into class typeinfo which
will be taken into account during dynamic cast. Or remove interface from
classinfo.interfaces altogether (it should still be possible to cast known
class to its known base class/interface statically, i.e. without dynamic cast).

I know the issue is not of high value but it should either be fixed for
consistency, or protection inheritance attributes should be removed from


Reply via email to