Skip to content

Commit f90a501

Browse files
committed
Merge remote-tracking branch 'origin/master' into master-rebranch
2 parents 051159f + 88bc5b8 commit f90a501

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

lib/ClangImporter/ImportType.cpp

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -891,20 +891,23 @@ namespace {
891891
unsigned typeParamCount = imported->getGenericParams()->size();
892892
auto typeArgs = type->getObjectType()->getTypeArgs();
893893
assert(typeArgs.empty() || typeArgs.size() == typeParamCount);
894-
llvm::SmallVector<Type, 2> importedTypeArgs;
895-
for (unsigned i = 0; i < typeParamCount; i++) {
896-
Type importedTypeArg;
897-
auto typeParam = imported->getGenericParams()->getParams()[i];
898-
if (!typeArgs.empty()) {
899-
auto subresult = Visit(typeArgs[i]);
900-
if (!subresult) {
894+
SmallVector<Type, 2> importedTypeArgs;
895+
importedTypeArgs.reserve(typeParamCount);
896+
if (!typeArgs.empty()) {
897+
for (auto typeArg : typeArgs) {
898+
Type importedTypeArg = Visit(typeArg).AbstractType;
899+
if (!importedTypeArg)
901900
return nullptr;
901+
importedTypeArgs.push_back(importedTypeArg);
902+
}
903+
} else {
904+
for (auto typeParam : imported->getGenericParams()->getParams()) {
905+
if (typeParam->getSuperclass() &&
906+
typeParam->getConformingProtocols().empty()) {
907+
importedTypeArgs.push_back(typeParam->getSuperclass());
908+
continue;
902909
}
903-
importedTypeArg = subresult.AbstractType;
904-
} else if (typeParam->getSuperclass() &&
905-
typeParam->getConformingProtocols().empty()) {
906-
importedTypeArg = typeParam->getSuperclass();
907-
} else {
910+
908911
SmallVector<Type, 4> memberTypes;
909912

910913
if (auto superclassType = typeParam->getSuperclass())
@@ -917,11 +920,11 @@ namespace {
917920
if (memberTypes.empty())
918921
hasExplicitAnyObject = true;
919922

920-
importedTypeArg = ProtocolCompositionType::get(
923+
Type importedTypeArg = ProtocolCompositionType::get(
921924
Impl.SwiftContext, memberTypes,
922925
hasExplicitAnyObject);
926+
importedTypeArgs.push_back(importedTypeArg);
923927
}
924-
importedTypeArgs.push_back(importedTypeArg);
925928
}
926929
assert(importedTypeArgs.size() == typeParamCount);
927930
importedType = BoundGenericClassType::get(

0 commit comments

Comments
 (0)