@@ -3108,54 +3108,6 @@ namespace {
3108
3108
}
3109
3109
}
3110
3110
3111
- // / Map an init method to a Swift declaration name.
3112
- // /
3113
- // / Some special cased remappings also change the parameter signature of the
3114
- // / imported initializer, such as to drop vararg parameters.
3115
- // /
3116
- // / All parameters are in/out parameters.
3117
- DeclName
3118
- mapInitSelectorToDeclName (ObjCSelector &selector,
3119
- ArrayRef<const clang::ParmVarDecl *> &args,
3120
- bool &variadic,
3121
- bool isSwiftPrivate) {
3122
- auto &C = Impl.SwiftContext ;
3123
-
3124
- // Map a few initializers to non-variadic versions that drop the
3125
- // variadic parameter.
3126
- if (variadic && shouldMakeSelectorNonVariadic (selector)) {
3127
- selector = ObjCSelector (C, selector.getNumArgs () - 1 ,
3128
- selector.getSelectorPieces ().slice (0 ,
3129
- selector.getSelectorPieces ().size () - 1 ));
3130
- args = args.slice (0 , args.size () - 1 );
3131
- variadic = false ;
3132
- }
3133
-
3134
- return Impl.mapSelectorToDeclName (selector, /* initializer*/ true ,
3135
- isSwiftPrivate);
3136
- }
3137
-
3138
- static bool shouldMakeSelectorNonVariadic (ObjCSelector selector) {
3139
- // This is UIActionSheet's designated initializer.
3140
- if (selector.isNonNullarySelector ({ " initWithTitle" ,
3141
- " delegate" ,
3142
- " cancelButtonTitle" ,
3143
- " destructiveButtonTitle" ,
3144
- " otherButtonTitles" }))
3145
- return true ;
3146
-
3147
- // This is UIAlertView's designated initializer.
3148
- if (selector.isNonNullarySelector ({ " initWithTitle" ,
3149
- " message" ,
3150
- " delegate" ,
3151
- " cancelButtonTitle" ,
3152
- " otherButtonTitles" }))
3153
- return true ;
3154
-
3155
- // Nothing else for now.
3156
- return false ;
3157
- }
3158
-
3159
3111
// / \brief Given an imported method, try to import it as a constructor.
3160
3112
// /
3161
3113
// / Objective-C methods in the 'init' family are imported as
@@ -3188,14 +3140,21 @@ namespace {
3188
3140
objcMethod->param_begin (),
3189
3141
objcMethod->param_end ()
3190
3142
};
3191
- bool isSwiftPrivate = objcMethod-> hasAttr <clang::SwiftPrivateAttr>();
3143
+
3192
3144
bool variadic = objcMethod->isVariadic ();
3193
- DeclName name = mapInitSelectorToDeclName (selector, params, variadic,
3194
- isSwiftPrivate);
3145
+ auto importedName = Impl.importFullName (objcMethod);
3146
+ if (!importedName) return nullptr ;
3147
+
3148
+ // If we dropped the variadic, handle it now.
3149
+ if (importedName.DroppedVariadic ) {
3150
+ params = params.slice (1 );
3151
+ variadic = false ;
3152
+ }
3195
3153
3196
3154
bool redundant;
3197
3155
return importConstructor (objcMethod, dc, implicit, kind, required,
3198
- selector, name, /* customName=*/ false , params,
3156
+ selector, importedName,
3157
+ importedName.HasCustomName , params,
3199
3158
variadic, redundant);
3200
3159
}
3201
3160
0 commit comments