From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32020 invoked by alias); 11 Oct 2004 22:04:09 -0000 Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org Received: (qmail 32011 invoked from network); 11 Oct 2004 22:04:08 -0000 Received: from unknown (HELO mail-out3.apple.com) (17.254.13.22) by sourceware.org with SMTP; 11 Oct 2004 22:04:08 -0000 Received: from mailgate2.apple.com (a17-128-100-204.apple.com [17.128.100.204]) by mail-out3.apple.com (8.12.11/8.12.11) with ESMTP id i9BM8SF5008092 for ; Mon, 11 Oct 2004 15:08:28 -0700 (PDT) Received: from relay1.apple.com (relay1.apple.com) by mailgate2.apple.com (Content Technologies SMTPRS 4.3.14) with ESMTP id ; Mon, 11 Oct 2004 15:04:07 -0700 Received: from [17.201.24.57] (polskifiat.apple.com [17.201.24.57]) by relay1.apple.com (8.12.11/8.12.11) with ESMTP id i9BM45Xk018834; Mon, 11 Oct 2004 15:04:06 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v619) Content-Type: text/plain; charset=US-ASCII; format=flowed Message-Id: <728118AE-1BD1-11D9-9ABE-000D9330C50E@apple.com> Content-Transfer-Encoding: 7bit Cc: David Ayers From: Ziemowit Laski Subject: RFC: Enhancing ObjC message lookup in the presence of protocols Date: Tue, 12 Oct 2004 06:11:00 -0000 To: gcc List , objc-language@lists.apple.com X-SW-Source: 2004-10/txt/msg00426.txt.bz2 This is a fallout from the work that David and I have been doing wrt adding 'Class ' support to the Objective-C language for the gcc 4.0 compiler (which hopefully will go in shortly, BTW). Given the code @protocol Proto - method1; + method2; @end @interface Base @end void foo(void) { Class cls; [cls method1]; } the compiler will currently warn: proto-ref.m:11: warning: `Class' may not respond to `+method1' proto-ref.m:11: warning: (Messages without a matching method signature proto-ref.m:11: warning: will be assumed to return `id' and accept proto-ref.m:11: warning: `...' as arguments.) Thing is, the compiler could do better in this case. Since the 'Base' class adopts the 'Proto' protocol, it is reasonable to assume that it will provide a '- method1' and a '+ method2'. Furthermore, since 'Base' is a root class in our example, '- method1' can be invoked as '+ method1', making the warning above superfluous. My proposal to attack this problem goes as follows: Whenever we see an interface or category declaration, we examine the protocols adopted by said interface/category and insert their constituent method signature into the global class or instance method hash tables (as is already being done for methods declared by the interface/category directly). Also, whenever we are dealing with a root class (or a category of a root class), we add any instance methods from the adopted protocols into the global class hash table (just as instance methods directly declared by root classes and categories already are). Such a fix should prevent us from issuing many superfluous warnings when messaging objects of type 'id', 'id ', 'Class' and (now) 'Class ', and will make things more consistent with what happens when you message a specific type (e.g., 'NSObject *'). What do you think? Does anyone have any objections to this? I'll be happy to clarify things if my missive is not understandable. :-) --Zem -------------------------------------------------------------- Ziemowit Laski 1 Infinite Loop, MS 301-2K Mac OS X Compiler Group Cupertino, CA USA 95014-2083 Apple Computer, Inc. +1.408.974.6229 Fax .5477