From patchwork Tue Nov 23 19:20:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: =?UTF-8?Q?libobjc=20-=20minor=20get=5Fimp=20fix?= X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 72740 Message-Id: <1290540055.277531931@192.168.2.229> To: "gcc-patches@gnu.org" Date: Tue, 23 Nov 2010 20:20:55 +0100 (CET) From: "Nicola Pero" List-Id: Patch from Richard Frith-Macdonald . Committed to trunk. Thanks Index: sendmsg.c =================================================================== --- sendmsg.c (revision 167090) +++ sendmsg.c (working copy) @@ -189,8 +189,13 @@ get_imp (Class class, SEL sel) /* The dispatch table has been installed, and the method is not in the dispatch table. So the method just doesn't exist for the class. Return the forwarding - implementation. */ - res = __objc_get_forward_imp ((id)class, sel); + implementation. We don't know the receiver (only its + class), so we have to pass 'nil' as the first + argument. Passing the class as first argument is + wrong because the class is not the receiver; it can + result in us calling a class method when we want an + instance method of the same name. */ + res = __objc_get_forward_imp (nil, sel); } } } Index: ChangeLog =================================================================== --- ChangeLog (revision 167090) +++ ChangeLog (working copy) @@ -1,3 +1,9 @@ +2010-11-23 Richard Frith-Macdonald + + * sendmsg.c (get_imp): Fixed call to __objc_get_forward_imp to + pass nil as the receiver since we don't know the receiver at this + point. + 2010-11-18 Nicola Pero * ivars.c: Include stdlib.h.