Am 11.11.2011, 17:38 Uhr, schrieb Trass3r <[email protected]>:

Am 11.11.2011, 17:16 Uhr, schrieb Matthias Frei <[email protected]>:

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.

Wow, this works? I was just recently thinking about it. I don't think many languages allow implementations in interfaces and I appreciate it.

Reply via email to