digitalmars.D.learn - Problem with synchronized and overloaded methods
- Jacob Carlborg (19/19) Sep 12 2010 The following peace of code doesn't not compile using D2:
- Simen kjaeraas (8/25) Sep 12 2010 This seems to be a bug indeed. If you make Base shared, the problem
- Jacob Carlborg (4/32) Sep 13 2010 Filed as http://d.puremagic.com/issues/show_bug.cgi?id=4858
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? -- /Jacob Carlborg
Sep 12 2010
On Sun, 12 Sep 2010 20:39:44 +0200, Jacob Carlborg <doob 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
Sep 12 2010
On 2010-09-12 23:01, Simen kjaeraas wrote:On Sun, 12 Sep 2010 20:39:44 +0200, Jacob Carlborg <doob me.com> wrote:Filed as http://d.puremagic.com/issues/show_bug.cgi?id=4858 -- /Jacob CarlborgThe 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.
Sep 13 2010