@@ -1050,7 +1050,6 @@ namespace {
1050
1050
if (memberTypes.empty ())
1051
1051
hasExplicitAnyObject = true ;
1052
1052
1053
- // Generic arguments are always imported as existential types.
1054
1053
Type importedTypeArg = ExistentialType::get (
1055
1054
ProtocolCompositionType::get (
1056
1055
Impl.SwiftContext , memberTypes,
@@ -1183,6 +1182,9 @@ namespace {
1183
1182
}
1184
1183
}
1185
1184
1185
+ if (bridgedType->isConstraintType ())
1186
+ bridgedType = ExistentialType::get (bridgedType);
1187
+
1186
1188
return { importedType,
1187
1189
ImportHint (ImportHint::ObjCBridged, bridgedType) };
1188
1190
}
@@ -1203,9 +1205,9 @@ namespace {
1203
1205
members.push_back (proto->getDeclaredInterfaceType ());
1204
1206
}
1205
1207
1206
- importedType =
1208
+ importedType = ExistentialType::get (
1207
1209
ProtocolCompositionType::get (Impl.SwiftContext , members,
1208
- /* HasExplicitAnyObject=*/ false );
1210
+ /* HasExplicitAnyObject=*/ false )) ;
1209
1211
}
1210
1212
1211
1213
// Class or Class<P> maps to an existential metatype.
@@ -1283,32 +1285,6 @@ static bool isCFAudited(ImportTypeKind importKind) {
1283
1285
llvm_unreachable (" Invalid ImportTypeKind." );
1284
1286
}
1285
1287
1286
- // / True if the type can be an existential type in this context.
1287
- static bool isExistentialContext (ImportTypeKind importKind) {
1288
- switch (importKind) {
1289
- case ImportTypeKind::Abstract:
1290
- case ImportTypeKind::Typedef:
1291
- return false ;
1292
- case ImportTypeKind::Value:
1293
- case ImportTypeKind::ObjCCollectionElement:
1294
- case ImportTypeKind::Variable:
1295
- case ImportTypeKind::Result:
1296
- case ImportTypeKind::Enum:
1297
- case ImportTypeKind::RecordField:
1298
- case ImportTypeKind::AuditedVariable:
1299
- case ImportTypeKind::AuditedResult:
1300
- case ImportTypeKind::Parameter:
1301
- case ImportTypeKind::CompletionHandlerResultParameter:
1302
- case ImportTypeKind::CFRetainedOutParameter:
1303
- case ImportTypeKind::CFUnretainedOutParameter:
1304
- case ImportTypeKind::Property:
1305
- case ImportTypeKind::PropertyWithReferenceSemantics:
1306
- return true ;
1307
- }
1308
-
1309
- llvm_unreachable (" Invalid ImportTypeKind." );
1310
- }
1311
-
1312
1288
// / Turn T into Unmanaged<T>.
1313
1289
static Type getUnmanagedType (ClangImporter::Implementation &impl,
1314
1290
Type payloadType) {
@@ -1574,11 +1550,6 @@ static ImportedType adjustTypeForConcreteImport(
1574
1550
1575
1551
assert (importedType);
1576
1552
1577
- if (importedType->isConstraintType () &&
1578
- isExistentialContext (importKind)) {
1579
- importedType = ExistentialType::get (importedType);
1580
- }
1581
-
1582
1553
if (importKind == ImportTypeKind::RecordField &&
1583
1554
importedType->isAnyClassReferenceType () &&
1584
1555
!importedType->isForeignReferenceType ()) {
0 commit comments