@@ -413,6 +413,18 @@ RequirementSignatureRequestRQM::evaluate(Evaluator &evaluator,
413413 machine->computeRequirementDiagnostics (errors, proto->getLoc ());
414414 diagnoseRequirementErrors (ctx, errors,
415415 AllowConcreteTypePolicy::NestedAssocTypes);
416+
417+ for (auto *protocol : machine->System .getProtocols ()) {
418+ auto selfType = protocol->getSelfInterfaceType ();
419+ auto concrete = machine->getConcreteType (selfType,
420+ machine->getGenericParams (),
421+ protocol);
422+ if (!concrete || concrete->hasError ())
423+ continue ;
424+
425+ protocol->diagnose (diag::requires_generic_param_made_equal_to_concrete,
426+ selfType);
427+ }
416428 }
417429
418430 if (!machine->getErrors ()) {
@@ -859,8 +871,6 @@ InferredGenericSignatureRequestRQM::evaluate(
859871 : AllowConcreteTypePolicy::AssocTypes);
860872 }
861873
862- // FIXME: Handle allowConcreteGenericParams
863-
864874 // Don't bother splitting concrete equivalence classes if there were invalid
865875 // requirements, because the signature is not going to be ABI anyway.
866876 if (!errorFlags.contains (GenericSignatureErrorFlags::HasInvalidRequirements)) {
@@ -887,6 +897,30 @@ InferredGenericSignatureRequestRQM::evaluate(
887897 std::move (machine));
888898 }
889899
900+ if (!allowConcreteGenericParams && attempt == 0 &&
901+ ctx.LangOpts .RequirementMachineInferredSignatures ==
902+ RequirementMachineMode::Enabled) {
903+ for (auto genericParam : result.getInnermostGenericParams ()) {
904+ auto canonical = result.getCanonicalTypeInContext (genericParam);
905+
906+ if (genericParam->is <DependentMemberType>() ||
907+ canonical->is <DependentMemberType>())
908+ continue ;
909+
910+ if (canonical->hasError () || canonical->isEqual (genericParam))
911+ continue ;
912+
913+ if (canonical->isTypeParameter ()) {
914+ ctx.Diags .diagnose (loc, diag::requires_generic_params_made_equal,
915+ genericParam, result->getSugaredType (canonical));
916+ } else {
917+ ctx.Diags .diagnose (loc,
918+ diag::requires_generic_param_made_equal_to_concrete,
919+ genericParam);
920+ }
921+ }
922+ }
923+
890924 if (!errorFlags.contains (GenericSignatureErrorFlags::HasInvalidRequirements)) {
891925 // Check invariants.
892926 result.verify ();
0 commit comments