hi!
imagine there are two interfaces arranged via composite pattern, one of them has a dispose
method among other methods:
interface IComponent extends ILeaf {
...
function dispose() : void;
}
interface ILeaf {
...
}
some implementations have some more things in common (say an id
) so there are two more interfaces:
interface ICommonLeaf extends ILeaf {
function get id() : String;
}
interface ICommonComponent extends ICommonLeaf, IComponent {
}
so far so good. but there is another interface which also has a dispose
method:
interface ISomething {
...
function dispose() : void;
}
and ISomething
is inherited by ICommonLeaf:
interface ICommonLeaf extends ILeaf, ISomething {
function get id() : String;
}
As soon as the dispose
method is invoked on an instance which implements the ICommonComponent
interface, the compiler fails with an ambiguous reference error because ISomething
has a method called dispose
and ILeaf
also has a dispose
method, both living in different interfaces (IComponent, ISomething
) within the inheritace tree of ICommonComponent.
I wonder how to deal with the situation if
- the
IComponent
, theILeaf
and theISomething
can't change. - the composite structure must also work for for the
ICommonLeaf
&ICommonComponent
- implementations and the
ICommonLeaf
&ICommonComponent
must conform to theISomething
type.
this might be an actionscript-3 specific issue. i haven't tested how other languages (for instance java) handle stuff like this.