2
2
//
3
3
// This source file is part of the Swift.org open source project
4
4
//
5
- // Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5
+ // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
6
6
// Licensed under Apache License v2.0 with Runtime Library Exception
7
7
//
8
8
// See https://swift.org/LICENSE.txt for license information
@@ -1448,64 +1448,6 @@ ConstraintSystem::getTypeOfMemberReference(
1448
1448
return { openedType, type };
1449
1449
}
1450
1450
1451
- // Performance hack: if there are two generic overloads, and one is
1452
- // more specialized than the other, prefer the more-specialized one.
1453
- static void tryOptimizeGenericDisjunction (ConstraintSystem &cs,
1454
- ArrayRef<OverloadChoice> choices,
1455
- OverloadChoice *&favoredChoice) {
1456
- if (favoredChoice || choices.size () != 2 )
1457
- return ;
1458
-
1459
- const auto &choiceA = choices[0 ];
1460
- const auto &choiceB = choices[1 ];
1461
-
1462
- if (!choiceA.isDecl () || !choiceB.isDecl ())
1463
- return ;
1464
-
1465
- auto isViable = [](ValueDecl *decl) -> bool {
1466
- assert (decl);
1467
-
1468
- auto *AFD = dyn_cast<AbstractFunctionDecl>(decl);
1469
- if (!AFD || !AFD->isGeneric ())
1470
- return false ;
1471
-
1472
- auto funcType = AFD->getInterfaceType ();
1473
- auto hasAny = funcType.findIf ([](Type type) -> bool {
1474
- if (auto objType = type->getOptionalObjectType ())
1475
- return objType->isAny ();
1476
-
1477
- return type->isAny ();
1478
- });
1479
-
1480
- // If function declaration references `Any` or `Any?` type
1481
- // let's not attempt it, because it's unclear
1482
- // without solving which overload is going to be better.
1483
- return !hasAny;
1484
- };
1485
-
1486
- auto *declA = choiceA.getDecl ();
1487
- auto *declB = choiceB.getDecl ();
1488
-
1489
- if (!isViable (declA) || !isViable (declB))
1490
- return ;
1491
-
1492
- auto &TC = cs.TC ;
1493
- auto *DC = cs.DC ;
1494
-
1495
- switch (TC.compareDeclarations (DC, declA, declB)) {
1496
- case Comparison::Better:
1497
- favoredChoice = const_cast <OverloadChoice *>(&choiceA);
1498
- break ;
1499
-
1500
- case Comparison::Worse:
1501
- favoredChoice = const_cast <OverloadChoice *>(&choiceB);
1502
- break ;
1503
-
1504
- case Comparison::Unordered:
1505
- break ;
1506
- }
1507
- }
1508
-
1509
1451
void ConstraintSystem::addOverloadSet (Type boundType,
1510
1452
ArrayRef<OverloadChoice> choices,
1511
1453
DeclContext *useDC,
@@ -1520,8 +1462,6 @@ void ConstraintSystem::addOverloadSet(Type boundType,
1520
1462
return ;
1521
1463
}
1522
1464
1523
- tryOptimizeGenericDisjunction (*this , choices, favoredChoice);
1524
-
1525
1465
SmallVector<Constraint *, 4 > overloads;
1526
1466
1527
1467
// As we do for other favored constraints, if a favored overload has been
0 commit comments