@@ -4091,8 +4091,8 @@ namespace {
4091
4091
4092
4092
// / Check whether we have already imported a method with the given
4093
4093
// / selector in the given context.
4094
- bool isMethodAlreadyImported (ObjCSelector selector, bool isInstance ,
4095
- const DeclContext *dc,
4094
+ bool isMethodAlreadyImported (ObjCSelector selector, ImportedName importedName ,
4095
+ bool isInstance, const DeclContext *dc,
4096
4096
llvm::function_ref<bool (AbstractFunctionDecl *fn)> filter) {
4097
4097
// We only need to perform this check for classes.
4098
4098
auto classDecl
@@ -4108,6 +4108,7 @@ namespace {
4108
4108
for (auto decl : classDecl->lookupDirect (selector, isInstance)) {
4109
4109
if ((decl->getClangDecl ()
4110
4110
|| !decl->getDeclContext ()->getParentSourceFile ())
4111
+ && importedName.getDeclName () == decl->getFullName ()
4111
4112
&& filter (decl)) {
4112
4113
result = true ;
4113
4114
break ;
@@ -4175,25 +4176,25 @@ namespace {
4175
4176
}
4176
4177
}
4177
4178
4179
+ ImportedName importedName;
4180
+ Optional<ImportedName> correctSwiftName;
4181
+ importedName = importFullName (decl, correctSwiftName);
4182
+ if (!importedName)
4183
+ return nullptr ;
4184
+
4178
4185
// Check whether another method with the same selector has already been
4179
4186
// imported into this context.
4180
4187
ObjCSelector selector = Impl.importSelector (decl->getSelector ());
4181
4188
bool isInstance = decl->isInstanceMethod () && !forceClassMethod;
4182
4189
if (isActiveSwiftVersion ()) {
4183
- if (isMethodAlreadyImported (selector, isInstance, dc,
4190
+ if (isMethodAlreadyImported (selector, importedName, isInstance, dc,
4184
4191
[&](AbstractFunctionDecl *fn) {
4185
4192
return isAcceptableResult (fn, accessorInfo);
4186
4193
})) {
4187
4194
return nullptr ;
4188
4195
}
4189
4196
}
4190
4197
4191
- ImportedName importedName;
4192
- Optional<ImportedName> correctSwiftName;
4193
- importedName = importFullName (decl, correctSwiftName);
4194
- if (!importedName)
4195
- return nullptr ;
4196
-
4197
4198
// Normal case applies when we're importing an older name, or when we're
4198
4199
// not an init
4199
4200
if (!isFactoryInit (importedName)) {
@@ -6096,10 +6097,15 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
6096
6097
if (known != Impl.Constructors .end ())
6097
6098
return known->second ;
6098
6099
6100
+ Optional<ImportedName> correctSwiftName;
6101
+ auto importedName = importFullName (objcMethod, correctSwiftName);
6102
+ if (!importedName)
6103
+ return nullptr ;
6104
+
6099
6105
// Check whether there is already a method with this selector.
6100
6106
auto selector = Impl.importSelector (objcMethod->getSelector ());
6101
6107
if (isActiveSwiftVersion () &&
6102
- isMethodAlreadyImported (selector, /* isInstance=*/ true , dc,
6108
+ isMethodAlreadyImported (selector, importedName, /* isInstance=*/ true , dc,
6103
6109
[](AbstractFunctionDecl *fn) {
6104
6110
return true ;
6105
6111
}))
@@ -6110,10 +6116,6 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
6110
6116
objcMethod->param_end ()};
6111
6117
6112
6118
bool variadic = objcMethod->isVariadic ();
6113
- Optional<ImportedName> correctSwiftName;
6114
- auto importedName = importFullName (objcMethod, correctSwiftName);
6115
- if (!importedName)
6116
- return nullptr ;
6117
6119
6118
6120
// If we dropped the variadic, handle it now.
6119
6121
if (importedName.droppedVariadic ()) {
0 commit comments