@@ -791,6 +791,10 @@ InferredGenericSignatureRequest::evaluate(
791791 return false ;
792792 };
793793
794+ // "Local" generic parameters to which we apply default Copyable and
795+ // Escapable.
796+ SmallVector<Type, 4 > paramTypes;
797+
794798 if (genericParamList) {
795799 // Extensions never have a parent signature.
796800 assert (genericParamList->getOuterParameters () == nullptr || !parentSig);
@@ -807,6 +811,10 @@ InferredGenericSignatureRequest::evaluate(
807811 // We walk them backwards to order outer parameters before inner
808812 // parameters.
809813 for (auto *gpList : llvm::reverse (gpLists)) {
814+ for (auto *gpDecl : *gpList) {
815+ paramTypes.push_back (gpDecl->getDeclaredInterfaceType ());
816+ }
817+
810818 assert (gpList->size () > 0 &&
811819 " Parsed an empty generic parameter list?" );
812820
@@ -864,15 +872,16 @@ InferredGenericSignatureRequest::evaluate(
864872
865873 desugarRequirements (requirements, inverses, errors);
866874
875+ if (!genericParamList && allowConcreteGenericParams) {
876+ for (auto paramTy : genericParams) {
877+ paramTypes.push_back (paramTy);
878+ }
879+ }
880+
867881 // After realizing requirements, expand default requirements only for local
868882 // generic parameters, as the outer parameters have already been expanded.
869- SmallVector<Type, 4 > localGPs;
870- if (genericParamList)
871- for (auto *gtpd : genericParamList->getParams ())
872- localGPs.push_back (gtpd->getDeclaredInterfaceType ());
873-
874- InverseRequirement::expandDefaults (ctx, localGPs, requirements);
875- applyInverses (ctx, localGPs, inverses, requirements, errors);
883+ InverseRequirement::expandDefaults (ctx, paramTypes, requirements);
884+ applyInverses (ctx, paramTypes, inverses, requirements, errors);
876885
877886 // Re-order requirements so that inferred requirements appear last. This
878887 // ensures that if an inferred requirement is redundant with some other
@@ -947,7 +956,7 @@ InferredGenericSignatureRequest::evaluate(
947956 if (attempt == 0 ) {
948957 machine->computeRequirementDiagnostics (errors, inverses, loc);
949958 diagnoseRequirementErrors (ctx, errors,
950- allowConcreteGenericParams
959+ ( allowConcreteGenericParams || !genericParamList)
951960 ? AllowConcreteTypePolicy::All
952961 : AllowConcreteTypePolicy::AssocTypes);
953962 }
@@ -978,7 +987,7 @@ InferredGenericSignatureRequest::evaluate(
978987 std::move (machine));
979988 }
980989
981- if (!allowConcreteGenericParams) {
990+ if (genericParamList && !allowConcreteGenericParams) {
982991 for (auto genericParam : result.getInnermostGenericParams ()) {
983992 auto reduced = result.getReducedType (genericParam);
984993
0 commit comments