[cfe-dev] Bug (and patch) in objc method lookup

steve naroff snaroff at apple.com
Thu Feb 26 03:33:20 PST 2009


Thanks for the test/fix!

http://llvm.org/viewvc/llvm-project?rev=65526&view=rev

snaroff

On Feb 26, 2009, at 5:22 AM, Jean-Daniel Dupas wrote:

>
> A path to solve a method lookup issue with protocol chain.
> Uses lookupClassMethod()  and lookupInstanceMethod() instead of  
> getClassMethod() and getInstanceMethod() on each declared protocol,  
> so clang will also search in inherited protocol and not just in the  
> leaf protocol.
>
> <protocol-lookup.patch>
>
> A simple example to explain the problem:
>
> -------------------------------- protocol-chain.m  
> --------------------------------
> @protocol ProtocolA
>
> + (id)classMethod;
> - (id)instanceMethod;
>
> @end
>
> @protocol ProtocolB <ProtocolA>
>
> @end
>
> @interface Foo : NSObject <ProtocolB> { }
>
> @end
>
> @interface SubFoo : Foo { }
>
> @end
>
> @implementation SubFoo
>
> + (id)method {
>   return [super classMethod];
> }
>
> - (id)method {
>   return [super instanceMethod];
> }
>
> @end
> ------------------------------------------------------------------------------------------------
> protocol-chain.m:30:10: warning: method '+classMethod' not found  
> (return type defaults to 'id')
>   return [super classMethod];
>          ^~~~~~~~~~~~~~~~~~~
> protocol-chain.m:34:10: warning: method '-instanceMethod' not found  
> (return type defaults to 'id')
>   return [super instanceMethod];
>          ^~~~~~~~~~~~~~~~~~~~~~
> 2 diagnostics generated.
>
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090226/81063ad1/attachment.html>


More information about the cfe-dev mailing list