Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for rule prefer_self_in_static_references #5118

Closed
2 tasks done
pm-dev opened this issue Jul 13, 2023 · 0 comments · Fixed by #5119
Closed
2 tasks done

False positive for rule prefer_self_in_static_references #5118

pm-dev opened this issue Jul 13, 2023 · 0 comments · Fixed by #5119
Assignees
Labels
bug Unexpected and reproducible misbehavior.

Comments

@pm-dev
Copy link

pm-dev commented Jul 13, 2023

New Issue Checklist

Describe the bug

The following is a triggering example with this rule enabled, yet it results in a compiler error:
error: covariant ‘Self’ type cannot be referenced from a stored property initializer

class A {
        static let start: Int = 0

        private(set) var current: Int = A.start {
             didSet {
                 self.foo()
             }
        }
}

This will incorrectly convert private(set) var current: Int = A.start { to private(set) var current: Int = Self.start {

However this rule works correctly and doesn't trigger without the didSet block:

class A {
        static let start: Int = 0
        private(set) var current: Int = A.start
}

Environment

  • SwiftLint version: 0.52.4
  • Installation method used: Homebrew
  • Which Xcode version are you using: Xcode 14.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Unexpected and reproducible misbehavior.
Projects
None yet
2 participants