Skip to content

Commit f595ca7

Browse files
committed
[Clang importer] Rename ImportTypeKind::ObjCGenericArgument -> ObjCCollectionElement.
This better describes what we're importing. Also note why we need to reset to the block representation.
1 parent d529002 commit f595ca7

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ namespace {
974974
// Convert the type arguments.
975975
for (auto typeArg : typeArgs) {
976976
Type importedTypeArg = Impl.importTypeIgnoreIUO(
977-
typeArg, ImportTypeKind::ObjCGenericArgument,
977+
typeArg, ImportTypeKind::ObjCCollectionElement,
978978
AllowNSUIntegerAsInt, Bridging, OTK_None);
979979
if (!importedTypeArg) {
980980
importedTypeArgs.clear();
@@ -1102,7 +1102,7 @@ static bool canBridgeTypes(ImportTypeKind importKind) {
11021102
case ImportTypeKind::CFUnretainedOutParameter:
11031103
case ImportTypeKind::Property:
11041104
case ImportTypeKind::PropertyWithReferenceSemantics:
1105-
case ImportTypeKind::ObjCGenericArgument:
1105+
case ImportTypeKind::ObjCCollectionElement:
11061106
case ImportTypeKind::Typedef:
11071107
return true;
11081108
}
@@ -1116,7 +1116,7 @@ static bool isCFAudited(ImportTypeKind importKind) {
11161116
case ImportTypeKind::Abstract:
11171117
case ImportTypeKind::Typedef:
11181118
case ImportTypeKind::Value:
1119-
case ImportTypeKind::ObjCGenericArgument:
1119+
case ImportTypeKind::ObjCCollectionElement:
11201120
case ImportTypeKind::Variable:
11211121
case ImportTypeKind::Result:
11221122
case ImportTypeKind::Pointee:
@@ -1287,12 +1287,17 @@ static ImportedType adjustTypeForConcreteImport(
12871287
// we would prefer to instead use the default Swift convention.
12881288
if (hint == ImportHint::Block) {
12891289
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.
12941299
auto requiredFunctionTypeRepr = FunctionTypeRepresentation::Swift;
1295-
if (importKind == ImportTypeKind::ObjCGenericArgument) {
1300+
if (importKind == ImportTypeKind::ObjCCollectionElement) {
12961301
requiredFunctionTypeRepr = FunctionTypeRepresentation::Block;
12971302
}
12981303

lib/ClangImporter/ImporterImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ enum class ImportTypeKind {
109109
Value,
110110

111111
/// \brief Import the type of an Objective-C generic argument.
112-
ObjCGenericArgument,
112+
ObjCCollectionElement,
113113

114114
/// \brief Import the declared type of a variable.
115115
Variable,

0 commit comments

Comments
 (0)