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
@@ -1410,64 +1410,6 @@ ConstraintSystem::getTypeOfMemberReference(
1410
1410
return { openedType, type };
1411
1411
}
1412
1412
1413
- // Performance hack: if there are two generic overloads, and one is
1414
- // more specialized than the other, prefer the more-specialized one.
1415
- static void tryOptimizeGenericDisjunction (ConstraintSystem &cs,
1416
- ArrayRef<OverloadChoice> choices,
1417
- OverloadChoice *&favoredChoice) {
1418
- if (favoredChoice || choices.size () != 2 )
1419
- return ;
1420
-
1421
- const auto &choiceA = choices[0 ];
1422
- const auto &choiceB = choices[1 ];
1423
-
1424
- if (!choiceA.isDecl () || !choiceB.isDecl ())
1425
- return ;
1426
-
1427
- auto isViable = [](ValueDecl *decl) -> bool {
1428
- assert (decl);
1429
-
1430
- auto *AFD = dyn_cast<AbstractFunctionDecl>(decl);
1431
- if (!AFD || !AFD->isGeneric ())
1432
- return false ;
1433
-
1434
- auto funcType = AFD->getInterfaceType ();
1435
- auto hasAny = funcType.findIf ([](Type type) -> bool {
1436
- if (auto objType = type->getOptionalObjectType ())
1437
- return objType->isAny ();
1438
-
1439
- return type->isAny ();
1440
- });
1441
-
1442
- // If function declaration references `Any` or `Any?` type
1443
- // let's not attempt it, because it's unclear
1444
- // without solving which overload is going to be better.
1445
- return !hasAny;
1446
- };
1447
-
1448
- auto *declA = choiceA.getDecl ();
1449
- auto *declB = choiceB.getDecl ();
1450
-
1451
- if (!isViable (declA) || !isViable (declB))
1452
- return ;
1453
-
1454
- auto &TC = cs.TC ;
1455
- auto *DC = cs.DC ;
1456
-
1457
- switch (TC.compareDeclarations (DC, declA, declB)) {
1458
- case Comparison::Better:
1459
- favoredChoice = const_cast <OverloadChoice *>(&choiceA);
1460
- break ;
1461
-
1462
- case Comparison::Worse:
1463
- favoredChoice = const_cast <OverloadChoice *>(&choiceB);
1464
- break ;
1465
-
1466
- case Comparison::Unordered:
1467
- break ;
1468
- }
1469
- }
1470
-
1471
1413
void ConstraintSystem::addOverloadSet (Type boundType,
1472
1414
ArrayRef<OverloadChoice> choices,
1473
1415
DeclContext *useDC,
@@ -1482,8 +1424,6 @@ void ConstraintSystem::addOverloadSet(Type boundType,
1482
1424
return ;
1483
1425
}
1484
1426
1485
- tryOptimizeGenericDisjunction (*this , choices, favoredChoice);
1486
-
1487
1427
SmallVector<Constraint *, 4 > overloads;
1488
1428
1489
1429
// As we do for other favored constraints, if a favored overload has been
0 commit comments