Re: Initing sublacss with superclass method
Frederik Seiffert <[email protected]> Fri, 11 Jul 2025 09:42:11 -0700
| Newsgroups | gmane.comp.lib.gnustep.devel |
|---|---|
| Message-ID | <CADvpqz89hMQ5x=c+cOdM+XeJQ3G20pDtwxNNqV5OVOcXqj0sKQ@mail.gmail.com> |
--000000000000e0ed9b0639a9fd84 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Riccardo, Am 11.07.2025, 15:17:25 schrieb Riccardo Mottola <[email protected]= t >: > > Shouldn't thus the method called on the subclass still return a valid > subclass and not the superclass? > > Could it be a header issue? we define it as: > + (NSCharacterSet*) characterSetWithCharactersInString: (NSString*)aStrin= g; > > maybe it should return instancetype? > I had changed these return types from id to NSCharacterSet in https://github.com/gnustep/libs-base/pull/501, because that is what the implementation returns by calling =E2=80=9Ecopy=E2=80=9C on the created set= before returning. This matches Apple platforms both in the implementation and header declaration. Frederik --000000000000e0ed9b0639a9fd84 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <html><body><div dir=3D"ltr">Hi Riccardo,</div> <br> <div class=3D"gmail_quote"> <div dir=3D"ltr" class=3D"gmail_attr">Am 11.07.2025, 15:17:25 schrieb R= iccardo Mottola <<a href=3D"mailto:[email protected]">riccardo.= [email protected]</a>>:<br></div> <blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bor= der-left:1px solid rgb(204,204,204);padding-left:1ex" type=3D"cite"> =20 <div> <div><br>Shouldn't thus the method called on the subclass still return = a valid<br>subclass and not the superclass?<br><br>Could it be a header iss= ue? we define it as:<br>+ (NSCharacterSet*) characterSetWithCharactersInStr= ing: (NSString*)aString;<br><br>maybe it should return instancetype?<br> </div> </div> </blockquote><br> </div><div class=3D"gmail_quote" dir=3D"ltr">I had changed these return typ= es from id to NSCharacterSet in <a href=3D"https://github.com/gnustep/libs-= base/pull/501">https://github.com/gnustep/libs-base/pull/501</a>, because t= hat is what the implementation returns by calling =E2=80=9Ecopy=E2=80=9C on= the created set before returning. This matches Apple platforms both in the= implementation and header declaration.</div><div class=3D"gmail_quote" dir= =3D"ltr"><br></div><div class=3D"gmail_quote" dir=3D"ltr">Frederik</div><di= v class=3D"gmail_quote" dir=3D"ltr"><br></div></body></html> --000000000000e0ed9b0639a9fd84--