@@ -891,20 +891,23 @@ namespace {
891
891
unsigned typeParamCount = imported->getGenericParams ()->size ();
892
892
auto typeArgs = type->getObjectType ()->getTypeArgs ();
893
893
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)
901
900
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 ;
902
909
}
903
- importedTypeArg = subresult.AbstractType ;
904
- } else if (typeParam->getSuperclass () &&
905
- typeParam->getConformingProtocols ().empty ()) {
906
- importedTypeArg = typeParam->getSuperclass ();
907
- } else {
910
+
908
911
SmallVector<Type, 4 > memberTypes;
909
912
910
913
if (auto superclassType = typeParam->getSuperclass ())
@@ -917,11 +920,11 @@ namespace {
917
920
if (memberTypes.empty ())
918
921
hasExplicitAnyObject = true ;
919
922
920
- importedTypeArg = ProtocolCompositionType::get (
923
+ Type importedTypeArg = ProtocolCompositionType::get (
921
924
Impl.SwiftContext , memberTypes,
922
925
hasExplicitAnyObject);
926
+ importedTypeArgs.push_back (importedTypeArg);
923
927
}
924
- importedTypeArgs.push_back (importedTypeArg);
925
928
}
926
929
assert (importedTypeArgs.size () == typeParamCount);
927
930
importedType = BoundGenericClassType::get (
0 commit comments