@@ -748,6 +748,27 @@ InferredGenericSignatureRequest::evaluate(
748748
749749 SmallVector<StructuralRequirement, 4 > requirements;
750750 SmallVector<RequirementError, 4 > errors;
751+
752+ SourceLoc loc = [&]() {
753+ if (genericParamList) {
754+ auto loc = genericParamList->getLAngleLoc ();
755+ if (loc.isValid ())
756+ return loc;
757+ }
758+ if (whereClause) {
759+ auto loc = whereClause.getLoc ();
760+ if (loc.isValid ())
761+ return loc;
762+ }
763+ for (auto sourcePair : inferenceSources) {
764+ auto *typeRepr = sourcePair.getTypeRepr ();
765+ auto loc = typeRepr ? typeRepr->getStartLoc () : SourceLoc ();
766+ if (loc.isValid ())
767+ return loc;
768+ }
769+ return SourceLoc ();
770+ }();
771+
751772 for (const auto &req : parentSig.getRequirements ())
752773 requirements.push_back ({req, SourceLoc (), /* wasInferred=*/ false });
753774
@@ -760,10 +781,7 @@ InferredGenericSignatureRequest::evaluate(
760781 return false ;
761782 };
762783
763- SourceLoc loc;
764784 if (genericParamList) {
765- loc = genericParamList->getLAngleLoc ();
766-
767785 // Extensions never have a parent signature.
768786 assert (genericParamList->getOuterParameters () == nullptr || !parentSig);
769787
@@ -810,9 +828,6 @@ InferredGenericSignatureRequest::evaluate(
810828 if (whereClause) {
811829 lookupDC = whereClause.dc ;
812830
813- if (loc.isInvalid ())
814- loc = whereClause.getLoc ();
815-
816831 std::move (whereClause).visitRequirements (
817832 TypeResolutionStage::Structural,
818833 visitRequirement);
@@ -825,8 +840,6 @@ InferredGenericSignatureRequest::evaluate(
825840 for (auto sourcePair : inferenceSources) {
826841 auto *typeRepr = sourcePair.getTypeRepr ();
827842 auto typeLoc = typeRepr ? typeRepr->getStartLoc () : SourceLoc ();
828- if (loc.isInvalid ())
829- loc = typeLoc;
830843
831844 inferRequirements (sourcePair.getType (), typeLoc, moduleForInference,
832845 lookupDC, requirements);
0 commit comments