Skip to content

Commit

Permalink
Merge pull request swiftlang#32401 from akyrtzi/fix-clang-include-inh…
Browse files Browse the repository at this point in the history
…erited-convenience-inits-for-members

[ClangImporter] Follow-up for swiftlang#32214, fix assertion hit due to missing check
  • Loading branch information
akyrtzi authored Jun 16, 2020
2 parents fe39c72 + f89a385 commit cc5335c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<clang::ObjCMethodDecl>(existing->getClangDecl());
Expand Down
3 changes: 3 additions & 0 deletions test/api-digester/Inputs/Foo-new-version/foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/api-digester/Inputs/Foo/foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
75 changes: 75 additions & 0 deletions test/api-digester/Outputs/clang-module-dump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit cc5335c

Please sign in to comment.