@@ -827,9 +827,6 @@ Type TypeResolution::applyUnboundGenericArguments(
827827 genericArgs.size () >= decl->getGenericParams ()->size () - 1 )) &&
828828 " invalid arguments, use applyGenericArguments for diagnostic emitting" );
829829
830- auto genericSig = decl->getGenericSignature ();
831- assert (!genericSig.isNull ());
832-
833830 TypeSubstitutionMap subs;
834831
835832 // Get the interface type for the declaration. We will be substituting
@@ -855,6 +852,7 @@ Type TypeResolution::applyUnboundGenericArguments(
855852 if (!resultType->hasTypeParameter ())
856853 return resultType;
857854
855+ auto genericSig = decl->getGenericSignature ();
858856 auto parentSig = decl->getDeclContext ()->getGenericSignatureOfContext ();
859857 for (auto gp : parentSig.getGenericParams ())
860858 subs[gp->getCanonicalType ()->castTo <GenericTypeParamType>()] =
@@ -864,18 +862,18 @@ Type TypeResolution::applyUnboundGenericArguments(
864862 }
865863
866864 skipRequirementsCheck |= parentTy->hasTypeVariable ();
867- } else if (auto genericSig =
865+ } else if (auto parentSig =
868866 decl->getDeclContext ()->getGenericSignatureOfContext ()) {
869- for (auto gp : genericSig .getGenericParams ()) {
867+ for (auto gp : parentSig .getGenericParams ()) {
870868 subs[gp->getCanonicalType ()->castTo <GenericTypeParamType>()] = gp;
871869 }
872870 }
873871
874872 // Realize the types of the generic arguments and add them to the
875873 // substitution map.
876- auto innerParams = genericSig. getInnermostGenericParams ();
877- for (unsigned i = 0 ; i < innerParams. size (); ++i ) {
878- auto origTy = innerParams[i];
874+ auto innerParams = decl-> getGenericParams ()-> getParams ();
875+ for (unsigned i : indices (innerParams) ) {
876+ auto origTy = innerParams[i]-> getDeclaredInterfaceType () ;
879877 auto origGP = origTy->getCanonicalType ()->castTo <GenericTypeParamType>();
880878
881879 if (!origGP->isTypeSequence ()) {
@@ -894,7 +892,8 @@ Type TypeResolution::applyUnboundGenericArguments(
894892 // types we can bind to this type sequence parameter.
895893 unsigned tail;
896894 for (tail = 1 ; tail <= innerParams.size (); ++tail) {
897- auto tailTy = innerParams[innerParams.size () - tail];
895+ auto tailTy = innerParams[innerParams.size () - tail]
896+ ->getDeclaredInterfaceType ();
898897 auto tailGP = tailTy->getCanonicalType ()->castTo <GenericTypeParamType>();
899898 if (tailGP->isTypeSequence ()) {
900899 assert (tailGP->isEqual (origGP) &&
@@ -943,6 +942,7 @@ Type TypeResolution::applyUnboundGenericArguments(
943942 if (noteLoc.isInvalid ())
944943 noteLoc = loc;
945944
945+ auto genericSig = decl->getGenericSignature ();
946946 auto result = TypeChecker::checkGenericArguments (
947947 module , loc, noteLoc,
948948 UnboundGenericType::get (decl, parentTy, getASTContext ()),
0 commit comments