• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning


  • Subject: Re: [Obj-C Compiler Bug?] Two different classes declaring a message with the same name - compiler warning
  • From: Greg Parker <email@hidden>
  • Date: Tue, 14 Oct 2008 18:24:06 -0700

Chris Suter wrote:
The proper way to solve this, in my opinion, is to allow a way of specifying that the return type varies depending on the class it's implemented on i.e. define the alloc method in such a way so that the compiler knows that -[<class> alloc] returns an object of type <class>. Something similar could be used for [NSString string] and [NSMutableString string] which have a similar problem (they return an id, rather than an NSString or NSMutableString).


We think so too.

<rdar://problem/4909520> ER: Declare that an instance method's return type is the same as the receiver's declared type.
<rdar://problem/4909545> ER: Declare that a class method's return type is the type of instances of the receiver.


The latter is the one that applies to +alloc. It returns an instance of the receiver object - which itself is a class - or some subclass thereof. The former is for things like -init, where the receiver type and the return type are the same.

There are a few binary- and source-compatibility issues to worry about, but the biggest reason this hasn't been done yet is simple lack of time.


-- Greg Parker email@hidden Runtime Wrangler


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Targetting 10.4
  • Next by Date: Re: Targetting 10.4
  • Previous by thread: Re: Targetting 10.4
  • Next by thread: -[NSGarbageCollection disableCollectorForPointer:] ?
  • Index(es):
    • Date
    • Thread