diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index 19810013c1aef..6ee66bc9003a5 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -7401,7 +7401,9 @@ void SwiftDeclConverter::importInheritedConstructors( Impl.importAttributes(objcMethod, newCtor, curObjCClass); newMembers.push_back(newCtor); - } else if (existing && existing->getClangDecl()) { + } else if (existing && existing->getInitKind() == + CtorInitializerKind::ConvenienceFactory && + existing->getClangDecl()) { // Check that the existing constructor the prevented new creation is // really an inherited factory initializer and not a class member. auto existingMD = cast(existing->getClangDecl()); diff --git a/test/api-digester/Inputs/Foo-new-version/foo.h b/test/api-digester/Inputs/Foo-new-version/foo.h index 536a81f66ee9e..9472cfaec3103 100644 --- a/test/api-digester/Inputs/Foo-new-version/foo.h +++ b/test/api-digester/Inputs/Foo-new-version/foo.h @@ -21,6 +21,9 @@ @interface PhotoSettings: NSObject + (instancetype)photoSettingsWithFormat:(int)format; + (instancetype)photoSettingsWithNumber:(int)number; + ++ (instancetype)photoSettingsWithCake:(int)cake; +- (instancetype)initWithCake:(int)cake; @end @interface PhotoBracketSettings : PhotoSettings diff --git a/test/api-digester/Inputs/Foo/foo.h b/test/api-digester/Inputs/Foo/foo.h index 54922ce83ac4e..5eba3467600e0 100644 --- a/test/api-digester/Inputs/Foo/foo.h +++ b/test/api-digester/Inputs/Foo/foo.h @@ -15,6 +15,9 @@ @interface PhotoSettings: NSObject + (instancetype)photoSettingsWithFormat:(int)format; + (instancetype)photoSettingsWithNumber:(int)number; + ++ (instancetype)photoSettingsWithCake:(int)cake; +- (instancetype)initWithCake:(int)cake; @end @interface PhotoBracketSettings : PhotoSettings diff --git a/test/api-digester/Outputs/clang-module-dump.txt b/test/api-digester/Outputs/clang-module-dump.txt index 9fcffbebb038b..43ec745788e68 100644 --- a/test/api-digester/Outputs/clang-module-dump.txt +++ b/test/api-digester/Outputs/clang-module-dump.txt @@ -324,6 +324,45 @@ ], "init_kind": "ConvenienceFactory" }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init(cake:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Foo.PhotoBracketSettings?", + "children": [ + { + "kind": "TypeNominal", + "name": "PhotoBracketSettings", + "printedName": "Foo.PhotoBracketSettings", + "usr": "c:objc(cs)PhotoBracketSettings" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "Int32", + "printedName": "Swift.Int32", + "usr": "s:s5Int32V" + } + ], + "declKind": "Constructor", + "usr": "c:objc(cs)PhotoSettings(im)initWithCake:", + "moduleName": "Foo", + "overriding": true, + "implicit": true, + "objc_name": "initWithCake:", + "declAttributes": [ + "Override", + "ObjC", + "Dynamic" + ], + "init_kind": "Designated" + }, { "kind": "Constructor", "name": "init", @@ -469,6 +508,42 @@ ], "init_kind": "ConvenienceFactory" }, + { + "kind": "Constructor", + "name": "init", + "printedName": "init(cake:)", + "children": [ + { + "kind": "TypeNominal", + "name": "Optional", + "printedName": "Foo.PhotoSettings?", + "children": [ + { + "kind": "TypeNominal", + "name": "PhotoSettings", + "printedName": "Foo.PhotoSettings", + "usr": "c:objc(cs)PhotoSettings" + } + ], + "usr": "s:Sq" + }, + { + "kind": "TypeNominal", + "name": "Int32", + "printedName": "Swift.Int32", + "usr": "s:s5Int32V" + } + ], + "declKind": "Constructor", + "usr": "c:objc(cs)PhotoSettings(im)initWithCake:", + "moduleName": "Foo", + "objc_name": "initWithCake:", + "declAttributes": [ + "ObjC", + "Dynamic" + ], + "init_kind": "Designated" + }, { "kind": "Constructor", "name": "init",