|
24 | 24 | #include "swift/AST/DiagnosticEngine.h"
|
25 | 25 | #include "swift/AST/DiagnosticsClangImporter.h"
|
26 | 26 | #include "swift/AST/ExistentialLayout.h"
|
| 27 | +#include "swift/AST/GenericEnvironment.h" |
27 | 28 | #include "swift/AST/GenericParamList.h"
|
28 | 29 | #include "swift/AST/GenericSignature.h"
|
29 | 30 | #include "swift/AST/Module.h"
|
@@ -1071,29 +1072,13 @@ namespace {
|
1071 | 1072 | importedTypeArgs.push_back(importedTypeArg);
|
1072 | 1073 | }
|
1073 | 1074 | } 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(); |
1085 | 1076 |
|
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(); |
1097 | 1082 | importedTypeArgs.push_back(importedTypeArg);
|
1098 | 1083 | }
|
1099 | 1084 | }
|
|
0 commit comments