Thread overview | |||||
---|---|---|---|---|---|
|
September 12, 2010 Problem with synchronized and overloaded methods | ||||
---|---|---|---|---|
| ||||
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
|
September 12, 2010 Re: Problem with synchronized and overloaded methods | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | 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 |
September 13, 2010 Re: Problem with synchronized and overloaded methods | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen kjaeraas | On 2010-09-12 23:01, Simen kjaeraas wrote: > 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. Filed as http://d.puremagic.com/issues/show_bug.cgi?id=4858 -- /Jacob Carlborg |
Copyright © 1999-2021 by the D Language Foundation