@@ -748,6 +748,27 @@ InferredGenericSignatureRequest::evaluate(
748
748
749
749
SmallVector<StructuralRequirement, 4 > requirements;
750
750
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
+
751
772
for (const auto &req : parentSig.getRequirements ())
752
773
requirements.push_back ({req, SourceLoc (), /* wasInferred=*/ false });
753
774
@@ -760,10 +781,7 @@ InferredGenericSignatureRequest::evaluate(
760
781
return false ;
761
782
};
762
783
763
- SourceLoc loc;
764
784
if (genericParamList) {
765
- loc = genericParamList->getLAngleLoc ();
766
-
767
785
// Extensions never have a parent signature.
768
786
assert (genericParamList->getOuterParameters () == nullptr || !parentSig);
769
787
@@ -810,9 +828,6 @@ InferredGenericSignatureRequest::evaluate(
810
828
if (whereClause) {
811
829
lookupDC = whereClause.dc ;
812
830
813
- if (loc.isInvalid ())
814
- loc = whereClause.getLoc ();
815
-
816
831
std::move (whereClause).visitRequirements (
817
832
TypeResolutionStage::Structural,
818
833
visitRequirement);
@@ -825,8 +840,6 @@ InferredGenericSignatureRequest::evaluate(
825
840
for (auto sourcePair : inferenceSources) {
826
841
auto *typeRepr = sourcePair.getTypeRepr ();
827
842
auto typeLoc = typeRepr ? typeRepr->getStartLoc () : SourceLoc ();
828
- if (loc.isInvalid ())
829
- loc = typeLoc;
830
843
831
844
inferRequirements (sourcePair.getType (), typeLoc, moduleForInference,
832
845
lookupDC, requirements);
0 commit comments