Skip to content

prefer_type_checking and optional types violation #5802

@cyberowl

Description

@cyberowl

New Issue Checklist

Bug Description

The following code causes false positive prefer_type_checking violation:

let value: String? = nil
print(value as Any? != nil) // -> false

Let's try fix it:

swiftlint . --fix

Now we got this:

let value: String? = nil
// xcodebuild warning: `'is' test is always true`
print(value is Any?) // -> now true, that's not expected

Environment

  • SwiftLint version: 0.57.0
  • Xcode version: 16.0 (16A242d)
  • Installation method used: Homebrew
  • Configuration file: None

Metadata

Metadata

Assignees

Labels

bugUnexpected and reproducible misbehavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions