@@ -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 ()) {
@@ -852,8 +864,6 @@ InferredGenericSignatureRequestRQM::evaluate(
852864 : AllowConcreteTypePolicy::AssocTypes);
853865 }
854866
855- // FIXME: Handle allowConcreteGenericParams
856-
857867 // Don't bother splitting concrete equivalence classes if there were invalid
858868 // requirements, because the signature is not going to be ABI anyway.
859869 if (!errorFlags.contains (GenericSignatureErrorFlags::HasInvalidRequirements)) {
@@ -880,6 +890,30 @@ InferredGenericSignatureRequestRQM::evaluate(
880890 std::move (machine));
881891 }
882892
893+ if (!allowConcreteGenericParams && attempt == 0 &&
894+ ctx.LangOpts .RequirementMachineInferredSignatures ==
895+ RequirementMachineMode::Enabled) {
896+ for (auto genericParam : result.getInnermostGenericParams ()) {
897+ auto canonical = result.getCanonicalTypeInContext (genericParam);
898+
899+ if (genericParam->is <DependentMemberType>() ||
900+ canonical->is <DependentMemberType>())
901+ continue ;
902+
903+ if (canonical->hasError () || canonical->isEqual (genericParam))
904+ continue ;
905+
906+ if (canonical->isTypeParameter ()) {
907+ ctx.Diags .diagnose (loc, diag::requires_generic_params_made_equal,
908+ genericParam, result->getSugaredType (canonical));
909+ } else {
910+ ctx.Diags .diagnose (loc,
911+ diag::requires_generic_param_made_equal_to_concrete,
912+ genericParam);
913+ }
914+ }
915+ }
916+
883917 if (!errorFlags.contains (GenericSignatureErrorFlags::HasInvalidRequirements)) {
884918 // Check invariants.
885919 result.verify ();
0 commit comments