@@ -1447,29 +1447,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
1447
1447
auto lhsType = CS.getType (lhsExpr)->getRValueType ();
1448
1448
auto rhsType = CS.getType (rhsExpr)->getRValueType ();
1449
1449
1450
- // TODO(diagnostics): There are still cases not yet handled by new
1451
- // diagnostics framework e.g.
1452
- //
1453
- // var tuple = (1, 2, 3)
1454
- // switch tuple {
1455
- // case (let (_, _, _)) + 1: break
1456
- // }
1457
- if (callExpr->isImplicit () && overloadName == " ~=" ) {
1458
- auto flags = ParameterTypeFlags ();
1459
- if (calleeInfo.candidates .size () == 1 )
1460
- if (auto fnType = calleeInfo.candidates [0 ].getFunctionType ())
1461
- flags = fnType->getParams ()[0 ].getParameterFlags ();
1462
-
1463
- auto *locator = CS.getConstraintLocator (
1464
- callExpr,
1465
- {ConstraintLocator::ApplyArgument,
1466
- LocatorPathElt::ApplyArgToParam (0 , 0 , flags)},
1467
- /* summaryFlags=*/ 0 );
1468
-
1469
- ArgumentMismatchFailure failure (CS, lhsType, rhsType, locator);
1470
- return failure.diagnosePatternMatchingMismatch ();
1471
- }
1472
-
1473
1450
if (isContextualConversionFailure (argTuple))
1474
1451
return false ;
1475
1452
@@ -1517,41 +1494,6 @@ bool FailureDiagnosis::visitApplyExpr(ApplyExpr *callExpr) {
1517
1494
AnyFunctionType::decomposeInput (CS.getType (argExpr), params);
1518
1495
auto argString = AnyFunctionType::getParamListAsString (params);
1519
1496
1520
- // If we couldn't get the name of the callee, then it must be something of a
1521
- // more complex "value of function type".
1522
- if (overloadName.empty ()) {
1523
- // If we couldn't infer the result type of the closure expr, then we have
1524
- // some sort of ambiguity, let the ambiguity diagnostic stuff handle this.
1525
- if (auto ffty = fnType->getAs <AnyFunctionType>())
1526
- if (ffty->getResult ()->hasTypeVariable ()) {
1527
- diagnoseAmbiguity (fnExpr);
1528
- return true ;
1529
- }
1530
-
1531
- // The most common unnamed value of closure type is a ClosureExpr, so
1532
- // special case it.
1533
- if (isa<ClosureExpr>(fnExpr->getValueProvidingExpr ())) {
1534
- if (fnType->hasTypeVariable ())
1535
- diagnose (argExpr->getStartLoc (), diag::cannot_invoke_closure, argString)
1536
- .highlight (fnExpr->getSourceRange ());
1537
- else
1538
- diagnose (argExpr->getStartLoc (), diag::cannot_invoke_closure_type,
1539
- fnType, argString)
1540
- .highlight (fnExpr->getSourceRange ());
1541
-
1542
- } else if (fnType->hasTypeVariable ()) {
1543
- diagnose (argExpr->getStartLoc (), diag::cannot_call_function_value,
1544
- argString)
1545
- .highlight (fnExpr->getSourceRange ());
1546
- } else {
1547
- diagnose (argExpr->getStartLoc (), diag::cannot_call_value_of_function_type,
1548
- fnType, argString)
1549
- .highlight (fnExpr->getSourceRange ());
1550
- }
1551
-
1552
- return true ;
1553
- }
1554
-
1555
1497
if (auto MTT = fnType->getAs <MetatypeType>()) {
1556
1498
if (MTT->getInstanceType ()->isExistentialType ()) {
1557
1499
diagnose (fnExpr->getLoc (), diag::construct_protocol_value, fnType);
@@ -1756,22 +1698,6 @@ void FailureDiagnosis::diagnoseAmbiguity(Expr *E) {
1756
1698
if (auto *assignment = dyn_cast<AssignExpr>(E)) {
1757
1699
if (isa<DiscardAssignmentExpr>(assignment->getDest ())) {
1758
1700
auto *srcExpr = assignment->getSrc ();
1759
-
1760
- bool diagnosedInvalidUseOfDiscardExpr = false ;
1761
- srcExpr->forEachChildExpr ([&](Expr *expr) -> Expr * {
1762
- if (auto *DAE = dyn_cast<DiscardAssignmentExpr>(expr)) {
1763
- diagnose (DAE->getLoc (), diag::discard_expr_outside_of_assignment)
1764
- .highlight (srcExpr->getSourceRange ());
1765
- diagnosedInvalidUseOfDiscardExpr = true ;
1766
- return nullptr ;
1767
- }
1768
-
1769
- return expr;
1770
- });
1771
-
1772
- if (diagnosedInvalidUseOfDiscardExpr)
1773
- return ;
1774
-
1775
1701
diagnoseAmbiguity (srcExpr);
1776
1702
return ;
1777
1703
}
@@ -1785,15 +1711,6 @@ void FailureDiagnosis::diagnoseAmbiguity(Expr *E) {
1785
1711
return ;
1786
1712
}
1787
1713
1788
- // A DiscardAssignmentExpr (spelled "_") needs contextual type information to
1789
- // infer its type. If we see one at top level, diagnose that it must be part
1790
- // of an assignment so we don't get a generic "expression is ambiguous" error.
1791
- if (isa<DiscardAssignmentExpr>(E)) {
1792
- diagnose (E->getLoc (), diag::discard_expr_outside_of_assignment)
1793
- .highlight (E->getSourceRange ());
1794
- return ;
1795
- }
1796
-
1797
1714
// Diagnose ".foo" expressions that lack context specifically.
1798
1715
if (auto UME =
1799
1716
dyn_cast<UnresolvedMemberExpr>(E->getSemanticsProvidingExpr ())) {
@@ -1805,22 +1722,6 @@ void FailureDiagnosis::diagnoseAmbiguity(Expr *E) {
1805
1722
}
1806
1723
}
1807
1724
1808
- // Diagnose empty collection literals that lack context specifically.
1809
- if (auto CE = dyn_cast<CollectionExpr>(E->getSemanticsProvidingExpr ())) {
1810
- if (CE->getNumElements () == 0 ) {
1811
- diagnose (E->getLoc (), diag::unresolved_collection_literal)
1812
- .highlight (E->getSourceRange ());
1813
- return ;
1814
- }
1815
- }
1816
-
1817
- // Diagnose 'nil' without a contextual type.
1818
- if (isa<NilLiteralExpr>(E->getSemanticsProvidingExpr ())) {
1819
- diagnose (E->getLoc (), diag::unresolved_nil_literal)
1820
- .highlight (E->getSourceRange ());
1821
- return ;
1822
- }
1823
-
1824
1725
// Attempt to re-type-check the entire expression, allowing ambiguity, but
1825
1726
// ignoring a contextual type.
1826
1727
if (expr == E) {
0 commit comments