Skip to content

Commit 472c863

Browse files
committed
ClangImporter: Clean up to use ArchetypeType::getExistentialType()
1 parent e98380c commit 472c863

File tree

1 file changed

+7
-22
lines changed

1 file changed

+7
-22
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "swift/AST/DiagnosticEngine.h"
2525
#include "swift/AST/DiagnosticsClangImporter.h"
2626
#include "swift/AST/ExistentialLayout.h"
27+
#include "swift/AST/GenericEnvironment.h"
2728
#include "swift/AST/GenericParamList.h"
2829
#include "swift/AST/GenericSignature.h"
2930
#include "swift/AST/Module.h"
@@ -1071,29 +1072,13 @@ namespace {
10711072
importedTypeArgs.push_back(importedTypeArg);
10721073
}
10731074
} else {
1074-
for (auto typeParam : imported->getGenericParams()->getParams()) {
1075-
if (typeParam->getSuperclass() &&
1076-
typeParam->getConformingProtocols().empty()) {
1077-
importedTypeArgs.push_back(typeParam->getSuperclass());
1078-
continue;
1079-
}
1080-
1081-
SmallVector<Type, 4> memberTypes;
1082-
1083-
if (auto superclassType = typeParam->getSuperclass())
1084-
memberTypes.push_back(superclassType);
1075+
auto *genericEnv = imported->getGenericEnvironment();
10851076

1086-
for (auto protocolDecl : typeParam->getConformingProtocols())
1087-
memberTypes.push_back(protocolDecl->getDeclaredInterfaceType());
1088-
1089-
bool hasExplicitAnyObject = false;
1090-
if (memberTypes.empty())
1091-
hasExplicitAnyObject = true;
1092-
1093-
Type importedTypeArg = ExistentialType::get(
1094-
ProtocolCompositionType::get(
1095-
Impl.SwiftContext, memberTypes,
1096-
hasExplicitAnyObject));
1077+
for (auto typeParam : imported->getGenericParams()->getParams()) {
1078+
Type importedTypeArg = genericEnv->mapTypeIntoContext(
1079+
typeParam->getDeclaredInterfaceType())
1080+
->castTo<ArchetypeType>()
1081+
->getExistentialType();
10971082
importedTypeArgs.push_back(importedTypeArg);
10981083
}
10991084
}

0 commit comments

Comments
 (0)