@@ -2824,7 +2824,7 @@ static Identifier typoCorrectNestedType(
2824
2824
// Look through all of the associated types of all of the protocols
2825
2825
// to which the parent conforms.
2826
2826
llvm::SmallVector<Identifier, 2 > bestMatches;
2827
- unsigned bestEditDistance = 0 ;
2827
+ unsigned bestEditDistance = UINT_MAX ;
2828
2828
unsigned maxScore = (name.size () + 1 ) / 3 ;
2829
2829
for (auto proto : pa->getParent ()->getConformsTo ()) {
2830
2830
for (auto member : getProtocolMembers (proto)) {
@@ -2836,16 +2836,12 @@ static Identifier typoCorrectNestedType(
2836
2836
/* AllowReplacements=*/ true ,
2837
2837
maxScore);
2838
2838
assert (dist > 0 && " nested type should have matched associated type" );
2839
- if (bestEditDistance == 0 || dist == bestEditDistance) {
2840
- bestEditDistance = dist;
2841
- maxScore = bestEditDistance;
2842
- bestMatches.push_back (assocType->getName ());
2843
- } else if (dist < bestEditDistance) {
2844
- bestEditDistance = dist;
2845
- maxScore = bestEditDistance;
2839
+ if (dist < bestEditDistance) {
2840
+ maxScore = bestEditDistance = dist;
2846
2841
bestMatches.clear ();
2847
- bestMatches.push_back (assocType->getName ());
2848
2842
}
2843
+ if (dist == bestEditDistance)
2844
+ bestMatches.push_back (assocType->getName ());
2849
2845
}
2850
2846
}
2851
2847
0 commit comments