diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-08-27 16:38:47 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-08-27 16:38:47 +0000 |
commit | fa0908f21915ffa5e0f4f2e4feda84b02b43e7ce (patch) | |
tree | b64f6153f1a7e0023933a5026c766081f7c6bc43 /lib/Sema/SemaOverload.cpp | |
parent | 8fd4641d99986e92613dbce3ee97dad6c09c0af8 (diff) |
Objective-C. When multiple nullary selectors are found in
global pool in the course of method selection for
a messaging expression, select one with the most general
return type of 'id'. This is to remove type-mismatch
warning (which is useless) as result of random selection of
method with more restrictive return type. rdar://18095772
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@216560 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r-- | lib/Sema/SemaOverload.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index 7bc42bfe9c..95b1dc0906 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -5743,10 +5743,20 @@ ObjCMethodDecl *Sema::SelectBestMethod(Selector Sel, MultiExprArg Args, break; } } - } else + } else { // Check for extra arguments to non-variadic methods. if (Args.size() != NumNamedArgs) Match = false; + else if (Match && NumNamedArgs == 0 && Methods.size() > 1) { + // Special case when selectors have no argument. In this case, select + // one with the most general result type of 'id'. + for (unsigned b = 0, e = Methods.size(); b < e; b++) { + QualType ReturnT = Methods[b]->getReturnType(); + if (ReturnT->isObjCIdType()) + return Methods[b]; + } + } + } if (Match) return Method; |