@@ -974,7 +974,7 @@ namespace {
974
974
// Convert the type arguments.
975
975
for (auto typeArg : typeArgs) {
976
976
Type importedTypeArg = Impl.importTypeIgnoreIUO (
977
- typeArg, ImportTypeKind::ObjCGenericArgument ,
977
+ typeArg, ImportTypeKind::ObjCCollectionElement ,
978
978
AllowNSUIntegerAsInt, Bridging, OTK_None);
979
979
if (!importedTypeArg) {
980
980
importedTypeArgs.clear ();
@@ -1102,7 +1102,7 @@ static bool canBridgeTypes(ImportTypeKind importKind) {
1102
1102
case ImportTypeKind::CFUnretainedOutParameter:
1103
1103
case ImportTypeKind::Property:
1104
1104
case ImportTypeKind::PropertyWithReferenceSemantics:
1105
- case ImportTypeKind::ObjCGenericArgument :
1105
+ case ImportTypeKind::ObjCCollectionElement :
1106
1106
case ImportTypeKind::Typedef:
1107
1107
return true ;
1108
1108
}
@@ -1116,7 +1116,7 @@ static bool isCFAudited(ImportTypeKind importKind) {
1116
1116
case ImportTypeKind::Abstract:
1117
1117
case ImportTypeKind::Typedef:
1118
1118
case ImportTypeKind::Value:
1119
- case ImportTypeKind::ObjCGenericArgument :
1119
+ case ImportTypeKind::ObjCCollectionElement :
1120
1120
case ImportTypeKind::Variable:
1121
1121
case ImportTypeKind::Result:
1122
1122
case ImportTypeKind::Pointee:
@@ -1287,12 +1287,17 @@ static ImportedType adjustTypeForConcreteImport(
1287
1287
// we would prefer to instead use the default Swift convention.
1288
1288
if (hint == ImportHint::Block) {
1289
1289
if (canBridgeTypes (importKind)) {
1290
- // Determine the representation we need. For Objective-C generic
1291
- // arguments, we cannot bridge them to a block, so force a block
1292
- // representation even if our imported type thus far is a Swift
1293
- // function representation.
1290
+ // Determine the function type representation we need.
1291
+ //
1292
+ // For Objective-C collection arguments, we cannot bridge from a block
1293
+ // to a Swift function type, so force the block representation. Normally
1294
+ // the mapped type will have a block representation (making this a no-op),
1295
+ // but in cases where the Clang type was written as a typedef of a
1296
+ // block type, that typedef will have a Swift function type
1297
+ // representation. This code will then break down the imported type
1298
+ // alias and produce a function type with block representation.
1294
1299
auto requiredFunctionTypeRepr = FunctionTypeRepresentation::Swift;
1295
- if (importKind == ImportTypeKind::ObjCGenericArgument ) {
1300
+ if (importKind == ImportTypeKind::ObjCCollectionElement ) {
1296
1301
requiredFunctionTypeRepr = FunctionTypeRepresentation::Block;
1297
1302
}
1298
1303
0 commit comments