@@ -1649,56 +1649,6 @@ class ExpandArrayIntoVarargsFailure final : public ContextualFailure {
1649
1649
void tryDropArrayBracketsFixIt (Expr *anchor) const ;
1650
1650
};
1651
1651
1652
- // / Diagnose a situation there is a mismatch between argument and parameter
1653
- // / types e.g.:
1654
- // /
1655
- // / ```swift
1656
- // / func foo(_: String) {}
1657
- // / func bar(_ v: Int) { foo(v) } // `Int` is not convertible to `String`
1658
- // / ```
1659
- class ArgumentMismatchFailure : public ContextualFailure {
1660
- public:
1661
- ArgumentMismatchFailure (Expr *root, ConstraintSystem &cs, Type argType,
1662
- Type paramType, ConstraintLocator *locator)
1663
- : ContextualFailure(root, cs, argType, paramType, locator) {}
1664
-
1665
- bool diagnoseAsError () override ;
1666
- bool diagnoseAsNote () override ;
1667
-
1668
- // / If both argument and parameter are represented by `ArchetypeType`
1669
- // / produce a special diagnostic in case their names match.
1670
- bool diagnoseArchetypeMismatch () const ;
1671
-
1672
- // / Tailored diagnostic for pattern matching with `~=` operator.
1673
- bool diagnosePatternMatchingMismatch () const ;
1674
-
1675
- // / Tailored diagnostics for argument mismatches associated with
1676
- // / reference equality operators `===` and `!==`.
1677
- bool diagnoseUseOfReferenceEqualityOperator () const ;
1678
-
1679
- protected:
1680
-
1681
- // / Situations like this:
1682
- // /
1683
- // / func foo(_: Int, _: String) {}
1684
- // / foo("")
1685
- // /
1686
- // / Are currently impossible to fix correctly,
1687
- // / so we have to attend to that in diagnostics.
1688
- bool diagnoseMisplacedMissingArgument () const ;
1689
-
1690
- SourceLoc getLoc () const { return getAnchor ()->getLoc (); }
1691
-
1692
- ValueDecl *getDecl () const {
1693
- auto selectedOverload = getChoiceFor (getLocator ());
1694
- if (!selectedOverload)
1695
- return nullptr ;
1696
-
1697
- auto choice = selectedOverload->choice ;
1698
- return choice.getDeclOrNull ();
1699
- }
1700
- };
1701
-
1702
1652
// / Provides information about the application of a function argument to a
1703
1653
// / parameter.
1704
1654
class FunctionArgApplyInfo {
@@ -1794,6 +1744,56 @@ class FunctionArgApplyInfo {
1794
1744
}
1795
1745
};
1796
1746
1747
+ // / Diagnose a situation there is a mismatch between argument and parameter
1748
+ // / types e.g.:
1749
+ // /
1750
+ // / ```swift
1751
+ // / func foo(_: String) {}
1752
+ // / func bar(_ v: Int) { foo(v) } // `Int` is not convertible to `String`
1753
+ // / ```
1754
+ class ArgumentMismatchFailure : public ContextualFailure {
1755
+ public:
1756
+ ArgumentMismatchFailure (Expr *root, ConstraintSystem &cs, Type argType,
1757
+ Type paramType, ConstraintLocator *locator)
1758
+ : ContextualFailure(root, cs, argType, paramType, locator) {}
1759
+
1760
+ bool diagnoseAsError () override ;
1761
+ bool diagnoseAsNote () override ;
1762
+
1763
+ // / If both argument and parameter are represented by `ArchetypeType`
1764
+ // / produce a special diagnostic in case their names match.
1765
+ bool diagnoseArchetypeMismatch () const ;
1766
+
1767
+ // / Tailored diagnostic for pattern matching with `~=` operator.
1768
+ bool diagnosePatternMatchingMismatch () const ;
1769
+
1770
+ // / Tailored diagnostics for argument mismatches associated with
1771
+ // / reference equality operators `===` and `!==`.
1772
+ bool diagnoseUseOfReferenceEqualityOperator () const ;
1773
+
1774
+ protected:
1775
+
1776
+ // / Situations like this:
1777
+ // /
1778
+ // / func foo(_: Int, _: String) {}
1779
+ // / foo("")
1780
+ // /
1781
+ // / Are currently impossible to fix correctly,
1782
+ // / so we have to attend to that in diagnostics.
1783
+ bool diagnoseMisplacedMissingArgument () const ;
1784
+
1785
+ SourceLoc getLoc () const { return getAnchor ()->getLoc (); }
1786
+
1787
+ ValueDecl *getDecl () const {
1788
+ auto selectedOverload = getChoiceFor (getLocator ());
1789
+ if (!selectedOverload)
1790
+ return nullptr ;
1791
+
1792
+ auto choice = selectedOverload->choice ;
1793
+ return choice.getDeclOrNull ();
1794
+ }
1795
+ };
1796
+
1797
1797
} // end namespace constraints
1798
1798
} // end namespace swift
1799
1799
0 commit comments