@@ -942,43 +942,56 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
942
942
SmallVector<ValueDecl *, 4 > lookupResults;
943
943
declContext->lookupQualified (typeDecl, renamedDeclName,
944
944
NL_QualifiedDefault, lookupResults);
945
- for (auto candidate : lookupResults) {
945
+
946
+ if (lookupResults.size () == 1 ) {
947
+ auto candidate = lookupResults[0 ];
946
948
if (!shouldInclude (candidate))
947
- continue ;
948
-
949
+ return nullptr ;
949
950
if (candidate->getKind () != D->getKind () ||
950
951
(candidate->isInstanceMember () !=
951
952
cast<ValueDecl>(D)->isInstanceMember ()))
952
- continue ;
953
-
954
- if (isa<FuncDecl>(candidate)) {
955
- auto cParams = cast<FuncDecl>(candidate)->getParameters ();
956
- auto dParams = cast<FuncDecl>(D)->getParameters ();
953
+ return nullptr ;
957
954
958
- if (cParams->size () != dParams->size ())
955
+ renamedDecl = candidate;
956
+ } else {
957
+ for (auto candidate : lookupResults) {
958
+ if (!shouldInclude (candidate))
959
959
continue ;
960
-
961
- bool hasSameParameterTypes = true ;
962
- for (auto index : indices (*cParams)) {
963
- auto cParamsType = cParams->get (index)->getType ();
964
- auto dParamsType = dParams->get (index)->getType ();
965
- if (!cParamsType->matchesParameter (dParamsType, TypeMatchOptions ())) {
966
- hasSameParameterTypes = false ;
967
- break ;
960
+
961
+ if (candidate->getKind () != D->getKind () ||
962
+ (candidate->isInstanceMember () !=
963
+ cast<ValueDecl>(D)->isInstanceMember ()))
964
+ continue ;
965
+
966
+ if (isa<FuncDecl>(candidate)) {
967
+ auto cParams = cast<FuncDecl>(candidate)->getParameters ();
968
+ auto dParams = cast<FuncDecl>(D)->getParameters ();
969
+
970
+ if (cParams->size () != dParams->size ())
971
+ continue ;
972
+
973
+ bool hasSameParameterTypes = true ;
974
+ for (auto index : indices (*cParams)) {
975
+ auto cParamsType = cParams->get (index)->getType ();
976
+ auto dParamsType = dParams->get (index)->getType ();
977
+ if (!cParamsType->matchesParameter (dParamsType, TypeMatchOptions ())) {
978
+ hasSameParameterTypes = false ;
979
+ break ;
980
+ }
981
+ }
982
+
983
+ if (!hasSameParameterTypes) {
984
+ continue ;
968
985
}
969
986
}
970
-
971
- if (!hasSameParameterTypes) {
972
- continue ;
987
+
988
+ if (renamedDecl) {
989
+ // If we found a duplicated candidate then we would silently fail.
990
+ renamedDecl = nullptr ;
991
+ break ;
973
992
}
993
+ renamedDecl = candidate;
974
994
}
975
-
976
- if (renamedDecl) {
977
- // If we found a duplicated candidate then we would silently fail.
978
- renamedDecl = nullptr ;
979
- break ;
980
- }
981
- renamedDecl = candidate;
982
995
}
983
996
return renamedDecl;
984
997
}
0 commit comments