@@ -4415,7 +4415,7 @@ namespace {
4415
4415
ConstructorDecl *importConstructor (const clang::ObjCMethodDecl *objcMethod,
4416
4416
DeclContext *dc,
4417
4417
bool implicit,
4418
- Optional< CtorInitializerKind> kindIn ,
4418
+ CtorInitializerKind kind ,
4419
4419
bool required,
4420
4420
ObjCSelector selector,
4421
4421
ImportedName importedName,
@@ -6081,9 +6081,10 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
6081
6081
}
6082
6082
6083
6083
bool redundant;
6084
- auto result =
6085
- importConstructor (objcMethod, dc, implicit, kind, required, selector,
6086
- importedName, params, variadic, redundant);
6084
+ auto result = importConstructor (objcMethod, dc, implicit,
6085
+ kind.getValueOr (importedName.getInitKind ()),
6086
+ required, selector, importedName, params,
6087
+ variadic, redundant);
6087
6088
6088
6089
// If this is a compatibility stub, mark it as such.
6089
6090
if (result && correctSwiftName)
@@ -6193,7 +6194,7 @@ bool SwiftDeclConverter::existingConstructorIsWorse(
6193
6194
// / constructor declaration appropriately.
6194
6195
ConstructorDecl *SwiftDeclConverter::importConstructor (
6195
6196
const clang::ObjCMethodDecl *objcMethod, DeclContext *dc, bool implicit,
6196
- Optional< CtorInitializerKind> kindIn , bool required, ObjCSelector selector,
6197
+ CtorInitializerKind kind , bool required, ObjCSelector selector,
6197
6198
ImportedName importedName, ArrayRef<const clang::ParmVarDecl *> args,
6198
6199
bool variadic, bool &redundant) {
6199
6200
redundant = false ;
@@ -6202,35 +6203,6 @@ ConstructorDecl *SwiftDeclConverter::importConstructor(
6202
6203
auto ownerNominal = dc->getSelfNominalTypeDecl ();
6203
6204
assert (ownerNominal && " Method in non-type context?" );
6204
6205
6205
- // Find the interface, if we can.
6206
- const clang::ObjCInterfaceDecl *interface = nullptr ;
6207
- if (auto classDecl = dyn_cast<ClassDecl>(ownerNominal)) {
6208
- interface =
6209
- dyn_cast_or_null<clang::ObjCInterfaceDecl>(classDecl->getClangDecl ());
6210
- }
6211
-
6212
- // If we weren't told what kind of initializer this should be,
6213
- // figure it out now.
6214
- CtorInitializerKind kind;
6215
-
6216
- if (kindIn) {
6217
- kind = *kindIn;
6218
-
6219
- // If we know this is a designated initializer, mark it as such.
6220
- if (interface && hasDesignatedInitializers (interface) &&
6221
- isDesignatedInitializer (interface, objcMethod))
6222
- kind = CtorInitializerKind::Designated;
6223
- } else {
6224
- // If the owning Objective-C class has designated initializers and this
6225
- // is not one of them, treat it as a convenience initializer.
6226
- if (interface && hasDesignatedInitializers (interface) &&
6227
- !isDesignatedInitializer (interface, objcMethod)) {
6228
- kind = CtorInitializerKind::Convenience;
6229
- } else {
6230
- kind = CtorInitializerKind::Designated;
6231
- }
6232
- }
6233
-
6234
6206
// Import the type that this method will have.
6235
6207
Optional<ForeignErrorConvention> errorConvention;
6236
6208
ParameterList *bodyParams;
@@ -7274,9 +7246,9 @@ void SwiftDeclConverter::importInheritedConstructors(
7274
7246
};
7275
7247
7276
7248
// The kind of initializer to import. If this class has designated
7277
- // initializers, everything it imports is a convenience initializer.
7249
+ // initializers, everything it inherits is a convenience initializer.
7278
7250
Optional<CtorInitializerKind> kind;
7279
- if (hasDesignatedInitializers (curObjCClass ))
7251
+ if (curObjCClass-> hasDesignatedInitializers ())
7280
7252
kind = CtorInitializerKind::Convenience;
7281
7253
7282
7254
0 commit comments