@@ -763,48 +763,14 @@ static void addKeyPathDynamicMemberOverloads(
763
763
}
764
764
}
765
765
766
- SolutionCompareResult compareSolutionsForCodeCompletion (
767
- ConstraintSystem &cs, ArrayRef<Solution> solutions, unsigned idx1,
768
- unsigned idx2) {
769
-
770
- // When solving for code completion we can't consider one solution worse than
771
- // another according to the same rules as regular compilation. For example,
772
- // with the code below:
773
- //
774
- // func foo(_ x: Int) -> Int {}
775
- // func foo<T>(_ x: T) -> String {}
776
- // foo(3).<complete here> // Still want solutions with for both foo
777
- // // overloads - String and Int members are both
778
- // // valid here.
779
- //
780
- // the comparison for regular compilation considers the solution with the more
781
- // specialized `foo` overload `foo(_: Int)` to be better than the solution
782
- // with the generic overload `foo(_: T)` even though both are otherwise
783
- // viable. For code completion purposes offering members of 'String' based
784
- // on the solution with the generic overload is equally as import as offering
785
- // members of 'Int' as choosing one of those completions will then result in
786
- // regular compilation resolving the call to the generic overload instead.
787
-
788
- if (solutions[idx1].getFixedScore () == solutions[idx2].getFixedScore ())
789
- return SolutionCompareResult::Incomparable;
790
- return solutions[idx1].getFixedScore () < solutions[idx2].getFixedScore ()
791
- ? SolutionCompareResult::Better
792
- : SolutionCompareResult::Worse;
793
- }
794
-
795
-
796
766
SolutionCompareResult ConstraintSystem::compareSolutions (
797
767
ConstraintSystem &cs, ArrayRef<Solution> solutions,
798
- const SolutionDiff &diff, unsigned idx1, unsigned idx2,
799
- bool isForCodeCompletion) {
768
+ const SolutionDiff &diff, unsigned idx1, unsigned idx2) {
800
769
if (cs.isDebugMode ()) {
801
770
llvm::errs ().indent (cs.solverState ->depth * 2 )
802
771
<< " comparing solutions " << idx1 << " and " << idx2 <<" \n " ;
803
772
}
804
773
805
- if (isForCodeCompletion)
806
- return compareSolutionsForCodeCompletion (cs, solutions, idx1, idx2);
807
-
808
774
// Whether the solutions are identical.
809
775
bool identical = true ;
810
776
@@ -1340,8 +1306,7 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
1340
1306
SmallVector<bool , 16 > losers (viable.size (), false );
1341
1307
unsigned bestIdx = 0 ;
1342
1308
for (unsigned i = 1 , n = viable.size (); i != n; ++i) {
1343
- switch (compareSolutions (*this , viable, diff, i, bestIdx,
1344
- isForCodeCompletion ())) {
1309
+ switch (compareSolutions (*this , viable, diff, i, bestIdx)) {
1345
1310
case SolutionCompareResult::Identical:
1346
1311
// FIXME: Might want to warn about this in debug builds, so we can
1347
1312
// find a way to eliminate the redundancy in the search space.
@@ -1365,8 +1330,7 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
1365
1330
if (i == bestIdx)
1366
1331
continue ;
1367
1332
1368
- switch (compareSolutions (*this , viable, diff, bestIdx, i,
1369
- isForCodeCompletion ())) {
1333
+ switch (compareSolutions (*this , viable, diff, bestIdx, i)) {
1370
1334
case SolutionCompareResult::Identical:
1371
1335
// FIXME: Might want to warn about this in debug builds, so we can
1372
1336
// find a way to eliminate the redundancy in the search space.
@@ -1418,8 +1382,7 @@ ConstraintSystem::findBestSolution(SmallVectorImpl<Solution> &viable,
1418
1382
if (losers[j])
1419
1383
continue ;
1420
1384
1421
- switch (compareSolutions (*this , viable, diff, i, j,
1422
- isForCodeCompletion ())) {
1385
+ switch (compareSolutions (*this , viable, diff, i, j)) {
1423
1386
case SolutionCompareResult::Identical:
1424
1387
// FIXME: Dub one of these the loser arbitrarily?
1425
1388
break ;
0 commit comments