mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Diagnostics] Diagnose comparisons with '.nan' and suggest using '.isNan' instead (#33860)
* [AST] Add 'FloatingPoint' known protocol kind * [Sema] Emit a diagnostic for comparisons with '.nan' instead of using '.isNan' * [Sema] Update '.nan' comparison diagnostic wording * [Sema] Explicitly check for either arguments to be '.nan' and tweak a comment * [Test] Tweak some comments * [Diagnostic] Change 'isNan' to 'isNaN' * [Sema] Fix a bug where firstArg was checked twice for FloatingPoint conformance and update some comments * [Test] Fix comments in test file * [NFC] Add a new 'isStandardComparisonOperator' method to 'Identifier' and use it in ConstraintSystem * [NFC] Reuse argument decl extraction code and switch over to the new 'isStandardComparisonOperator' method * [NFC] Update conformsToKnownProtocol to accept DeclContext and use it to check for FloatingPoint conformance
This commit is contained in:
@@ -165,7 +165,7 @@ Type FailureDiagnostic::restoreGenericParameters(
|
||||
bool FailureDiagnostic::conformsToKnownProtocol(
|
||||
Type type, KnownProtocolKind protocol) const {
|
||||
auto &cs = getConstraintSystem();
|
||||
return constraints::conformsToKnownProtocol(cs, type, protocol);
|
||||
return constraints::conformsToKnownProtocol(cs.DC, type, protocol);
|
||||
}
|
||||
|
||||
Type RequirementFailure::getOwnerType() const {
|
||||
|
||||
Reference in New Issue
Block a user