Non-Virtual Interface and Interface Implementation
Trass3r
un at known.com
Fri Nov 11 08:38:45 PST 2011
Am 11.11.2011, 17:16 Uhr, schrieb Matthias Frei <matfrei at ethz.ch>:
> Hi,
>
> i had the seemingly innocent idea to use the "NVI idiom" in the
> following way:
>
> interface Foo {
> void foo();
> }
>
> interface FooFoo : Foo {
> final void foo() {
> // do something with bar()
> }
> void bar();
> }
>
> class Bar : FooFoo {
> void bar() {
> // do something
> }
> }
>
> My idea was to check some default cases etc. in the FooFoo.foo() and
> call the bar() implementation from there.
>
> However it turned out that is is not possible:
> Error: class test.Bar interface function FooFoo.foo isn't implemented
>
> This is very weird, because of course Bar cannot implement foo() as it
> is declared final in FooFoo.
>
> Is there some particular reason that this does not work?
>
> Matthias
Probably a bug. final interface methods are relatively new, I guess nobody
has tested interfaces inheriting interfaces yet.
It also doesn't error on bar missing override.
More information about the Digitalmars-d
mailing list