@@ -2103,14 +2103,11 @@ Actual: ${stringify(fullActual)}`);
2103
2103
this . raiseError ( "verifyRangesInImplementationList failed - expected to find at least one implementation location but got 0" ) ;
2104
2104
}
2105
2105
2106
- for ( let i = 0 ; i < implementations . length ; i ++ ) {
2107
- for ( let j = 0 ; j < implementations . length ; j ++ ) {
2108
- if ( i !== j && implementationsAreEqual ( implementations [ i ] , implementations [ j ] ) ) {
2109
- const { textSpan, fileName } = implementations [ i ] ;
2110
- const end = textSpan . start + textSpan . length ;
2111
- this . raiseError ( `Duplicate implementations returned for range (${ textSpan . start } , ${ end } ) in ${ fileName } ` ) ;
2112
- }
2113
- }
2106
+ const duplicate = findDuplicatedElement ( implementations , implementationsAreEqual ) ;
2107
+ if ( duplicate ) {
2108
+ const { textSpan, fileName } = duplicate ;
2109
+ const end = textSpan . start + textSpan . length ;
2110
+ this . raiseError ( `Duplicate implementations returned for range (${ textSpan . start } , ${ end } ) in ${ fileName } ` ) ;
2114
2111
}
2115
2112
2116
2113
const ranges = this . getRanges ( ) ;
@@ -3756,6 +3753,16 @@ ${code}
3756
3753
function stripWhitespace ( s : string ) : string {
3757
3754
return s . replace ( / \s / g, "" ) ;
3758
3755
}
3756
+
3757
+ function findDuplicatedElement < T > ( a : ReadonlyArray < T > , equal : ( a : T , b : T ) => boolean ) : T {
3758
+ for ( let i = 0 ; i < a . length ; i ++ ) {
3759
+ for ( let j = i + 1 ; j < a . length ; j ++ ) {
3760
+ if ( equal ( a [ i ] , a [ j ] ) ) {
3761
+ return a [ i ] ;
3762
+ }
3763
+ }
3764
+ }
3765
+ }
3759
3766
}
3760
3767
3761
3768
namespace FourSlashInterface {
0 commit comments