Comment #0 by blazej.podsiadlo — 2011-07-07T13:20:14Z
Hi,
Linker fails to process following code when interface methods are private:
The same code with protected/public methods works fine...
-----------------------------
import std.stdio;
interface Foo {
private void foo();
public final void doFooFoo() {
foo();
foo();
};
};
class MyFoo : Foo {
override private void foo() {
writeln("foo()");
}
};
void main(string[] args) {
MyFoo mf = new MyFoo;
mf.doFooFoo();
writeln("Done.");
}
---------------------------
Undefined symbols for architecture i386:
"_D4stat3Foo3fooMFZv", referenced from:
_D4stat3Foo8doFooFooMFZv in stat.o
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status
--- errorlevel 1
Best Regards,
Blazej
Comment #1 by blazej.podsiadlo — 2011-07-07T13:21:50Z
Created attachment 1005
The object file compiled by dmd -c
orginal name was stat.o
Comment #2 by yebblies — 2011-07-07T23:08:56Z
private methods are implicitly final. It is correct that it fails to link, but it should be an error as MyFoo.foo does not override any function.
Comment #3 by yebblies — 2011-07-08T00:00:15Z
*** This issue has been marked as a duplicate of issue 3581 ***
Comment #4 by blazej.podsiadlo — 2011-07-10T11:49:48Z
Hi,
I'm not sure if all private methods should be implicitly final.
I've been trying to implement NVI (Non-Virtual Interface) Idiom found in Alexandrescu's book (p213).
Could you please make sure about that?
Thank you,
Blazej
Comment #5 by kennytm — 2011-07-10T11:54:22Z
(In reply to comment #4)
> Hi,
> I'm not sure if all private methods should be implicitly final.
> I've been trying to implement NVI (Non-Virtual Interface) Idiom found in
> Alexandrescu's book (p213).
> Could you please make sure about that?
> Thank you,
> Blazej
Please put the comment to bug 4542.
*** This issue has been marked as a duplicate of issue 3581 ***