From: Douglas Gregor Date: Sat, 11 Jun 2011 01:09:30 +0000 (+0000) Subject: Implement Objective-C Related Result Type semantics. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=926df6cfabf3eaa4afc990c097fa4619b76a9b57;p=clang Implement Objective-C Related Result Type semantics. Related result types apply Cocoa conventions to the type of message sends and property accesses to Objective-C methods that are known to always return objects whose type is the same as the type of the receiving class (or a subclass thereof), such as +alloc and -init. This tightens up static type safety for Objective-C, so that we now diagnose mistakes like this: t.m:4:10: warning: incompatible pointer types initializing 'NSSet *' with an expression of type 'NSArray *' [-Wincompatible-pointer-types] NSSet *array = [[NSArray alloc] init]; ^ ~~~~~~~~~~~~~~~~~~~~~~ /System/Library/Frameworks/Foundation.framework/Headers/NSObject.h:72:1: note: instance method 'init' is assumed to return an instance of its receiver type ('NSArray *') - (id)init; ^ It also means that we get decent type inference when writing code in Objective-C++0x: auto array = [[NSMutableArray alloc] initWithObjects:@"one", @"two",nil]; // ^ now infers NSMutableArray* rather than id git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132868 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LanguageExtensions.html b/docs/LanguageExtensions.html index bc8ecb1bc9..8f43725d82 100644 --- a/docs/LanguageExtensions.html +++ b/docs/LanguageExtensions.html @@ -62,6 +62,11 @@ td {
  • Checks for Type Traits
  • Blocks
  • +
  • Objective-C Features + +
  • Function Overloading in C
  • Builtin Functions