Problem with synchronized and overloaded methods

Jacob Carlborg doob at me.com
Mon Sep 13 01:13:29 PDT 2010


On 2010-09-12 23:01, Simen kjaeraas wrote:
> 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.

Filed as http://d.puremagic.com/issues/show_bug.cgi?id=4858

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list