Problem with synchronized and overloaded methods

Simen kjaeraas simen.kjaras at gmail.com
Sun Sep 12 14:01:20 PDT 2010


On Sun, 12 Sep 2010 20:39:44 +0200, Jacob Carlborg <doob at me.com> wrote:

> The following peace of code doesn't not compile using D2:
>
> class Base
> {
>      synchronized void func (string s) { }
>      synchronized void func (Object o) { }
> }
>
> class Foo : Base
> {
>      synchronized override void func (string key) { super.func(key); }
> }
>
> The compiler gives this error:
>
> main.d(13): Error: function main.Base.func (string s) shared is not  
> callable using argument types (string)
> main.d(13): Error: cannot implicitly convert expression (key) of type  
> string to object.Object
>
> If I remove "synchronized" from the method declarations I don't get this  
> error. What have I missed?

This seems to be a bug indeed. If you make Base shared, the problem
disappears, but now you have a shared class. I have not found this in
bugzilla, so please do file it.

Also, you can remove func(Object), as it is unrelated to the problem at
hand.

-- 
Simen


More information about the Digitalmars-d-learn mailing list