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:
@@ -1767,11 +1767,11 @@ namespace {
|
||||
|
||||
auto type = contextualType->lookThroughAllOptionalTypes();
|
||||
if (conformsToKnownProtocol(
|
||||
CS, type, KnownProtocolKind::ExpressibleByArrayLiteral))
|
||||
CS.DC, type, KnownProtocolKind::ExpressibleByArrayLiteral))
|
||||
return false;
|
||||
|
||||
return conformsToKnownProtocol(
|
||||
CS, type, KnownProtocolKind::ExpressibleByDictionaryLiteral);
|
||||
CS.DC, type, KnownProtocolKind::ExpressibleByDictionaryLiteral);
|
||||
};
|
||||
|
||||
if (isDictionaryContextualType(contextualType)) {
|
||||
|
||||
Reference in New Issue
Block a user