Skip to content

Commit 12c1db9

Browse files
committed
NFC: Move ArgumentMismatchFailure down a bit
Just to make sure it's defined after FunctionArgApplyInfo.
1 parent bb4f46f commit 12c1db9

File tree

1 file changed

+50
-50
lines changed

1 file changed

+50
-50
lines changed

lib/Sema/CSDiagnostics.h

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,56 +1649,6 @@ class ExpandArrayIntoVarargsFailure final : public ContextualFailure {
16491649
void tryDropArrayBracketsFixIt(Expr *anchor) const;
16501650
};
16511651

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-
17021652
/// Provides information about the application of a function argument to a
17031653
/// parameter.
17041654
class FunctionArgApplyInfo {
@@ -1794,6 +1744,56 @@ class FunctionArgApplyInfo {
17941744
}
17951745
};
17961746

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+
17971797
} // end namespace constraints
17981798
} // end namespace swift
17991799

0 commit comments

Comments
 (0)