@@ -919,82 +919,74 @@ class ObjCPrinter : private DeclVisitor<ObjCPrinter>,
919
919
auto renamedDeclName = renamedParsedDeclName.formDeclName (astContext);
920
920
921
921
if (isa<ClassDecl>(D) || isa<ProtocolDecl>(D)) {
922
+ if (!renamedParsedDeclName.ContextName .empty ()) {
923
+ return nullptr ;
924
+ }
922
925
UnqualifiedLookup lookup (renamedDeclName.getBaseIdentifier (),
923
926
declContext->getModuleScopeContext (), nullptr ,
924
927
SourceLoc (),
925
928
UnqualifiedLookup::Flags::TypeLookup);
926
929
return lookup.getSingleTypeResult ();
927
- } else {
928
- TypeDecl *typeDecl = declContext->getSelfNominalTypeDecl ();
929
-
930
- if (!renamedParsedDeclName.ContextName .empty ()) {
931
- auto contextIdentifier =
932
- astContext.getIdentifier (renamedParsedDeclName.ContextName );
933
- UnqualifiedLookup specificTypeLookup (
934
- contextIdentifier, declContext->getModuleScopeContext (), nullptr ,
935
- SourceLoc (), UnqualifiedLookup::Flags::TypeLookup);
936
- if (!specificTypeLookup.getSingleTypeResult ()) {
937
- return nullptr ;
938
- }
939
- }
940
-
941
- const ValueDecl *renamedDecl = nullptr ;
942
- SmallVector<ValueDecl *, 4 > lookupResults;
943
- declContext->lookupQualified (typeDecl, renamedDeclName,
944
- NL_QualifiedDefault, lookupResults);
930
+ }
931
+
932
+ TypeDecl *typeDecl = declContext->getSelfNominalTypeDecl ();
933
+
934
+ const ValueDecl *renamedDecl = nullptr ;
935
+ SmallVector<ValueDecl *, 4 > lookupResults;
936
+ declContext->lookupQualified (typeDecl, renamedDeclName,
937
+ NL_QualifiedDefault, lookupResults);
938
+
939
+ if (lookupResults.size () == 1 ) {
940
+ auto candidate = lookupResults[0 ];
941
+ if (!shouldInclude (candidate))
942
+ return nullptr ;
943
+ if (candidate->getKind () != D->getKind () ||
944
+ (candidate->isInstanceMember () !=
945
+ cast<ValueDecl>(D)->isInstanceMember ()))
946
+ return nullptr ;
945
947
946
- if (lookupResults.size () == 1 ) {
947
- auto candidate = lookupResults[0 ];
948
+ renamedDecl = candidate;
949
+ } else {
950
+ for (auto candidate : lookupResults) {
948
951
if (!shouldInclude (candidate))
949
- return nullptr ;
952
+ continue ;
953
+
950
954
if (candidate->getKind () != D->getKind () ||
951
955
(candidate->isInstanceMember () !=
952
956
cast<ValueDecl>(D)->isInstanceMember ()))
953
- return nullptr ;
954
-
955
- renamedDecl = candidate;
956
- } else {
957
- for (auto candidate : lookupResults) {
958
- if (!shouldInclude (candidate))
959
- continue ;
957
+ continue ;
958
+
959
+ if (isa<FuncDecl>(candidate)) {
960
+ auto cParams = cast<FuncDecl>(candidate)->getParameters ();
961
+ auto dParams = cast<FuncDecl>(D)->getParameters ();
960
962
961
- if (candidate->getKind () != D->getKind () ||
962
- (candidate->isInstanceMember () !=
963
- cast<ValueDecl>(D)->isInstanceMember ()))
963
+ if (cParams->size () != dParams->size ())
964
964
continue ;
965
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 ;
966
+ bool hasSameParameterTypes = true ;
967
+ for (auto index : indices (*cParams)) {
968
+ auto cParamsType = cParams->get (index)->getType ();
969
+ auto dParamsType = dParams->get (index)->getType ();
970
+ if (!cParamsType->matchesParameter (dParamsType, TypeMatchOptions ())) {
971
+ hasSameParameterTypes = false ;
972
+ break ;
985
973
}
986
974
}
987
975
988
- if (renamedDecl) {
989
- // If we found a duplicated candidate then we would silently fail.
990
- renamedDecl = nullptr ;
991
- break ;
976
+ if (!hasSameParameterTypes) {
977
+ continue ;
992
978
}
993
- renamedDecl = candidate;
994
979
}
980
+
981
+ if (renamedDecl) {
982
+ // If we found a duplicated candidate then we would silently fail.
983
+ renamedDecl = nullptr ;
984
+ break ;
985
+ }
986
+ renamedDecl = candidate;
995
987
}
996
- return renamedDecl;
997
988
}
989
+ return renamedDecl;
998
990
}
999
991
1000
992
void printRenameForDecl (const AvailableAttr *AvAttr, const ValueDecl *D,
0 commit comments