Skip to content

Commit

Permalink
Fix redundant public accessibility analysis false-positive for proper…
Browse files Browse the repository at this point in the history
…ty wrappers, closes #672
  • Loading branch information
ileitch committed Dec 19, 2023
1 parent d9fec3a commit f427a54
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- A newline is no longer printed before non-Xcode formatted results.
- `--external-codable-protocols` now retains enums that conform to `CodingKey`.
- Fix redundant public accessibility analysis false-positive for actors.
- Fix redundant public accessibility analysis false-positive for property wrappers.

## 2.17.1 (2023-12-04)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ final class RedundantExplicitPublicAccessibilityMarker: SourceGraphMutator {
}
}

return $0.parent
} else if decl.attributes.contains("propertyWrapper") {
return $0.parent
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,7 @@ let _ = PublicTypeUsedInPublicClosureRetainer().closure
Task {
await PublicActor().someFunc()
}

// Property wrappers

_ = PublicWrappedProperty().wrappedProperty
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Foundation

@propertyWrapper public struct PublicWrapper {
public var wrappedValue: String

public init(wrappedValue: String) {
self.wrappedValue = wrappedValue
}
}

public struct PublicWrappedProperty {
@PublicWrapper public var wrappedProperty: String

public init() {
wrappedProperty = ""
}
}
13 changes: 13 additions & 0 deletions Tests/AccessibilityTests/RedundantPublicAccessibilityTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,4 +259,17 @@ class RedundantPublicAccessibilityTest: SourceGraphTestCase {
self.assertNotRedundantPublicAccessibility(.functionMethodInstance("someFunc()"))
}
}

func testPublicWrappedProperty() {
Self.index()

assertNotRedundantPublicAccessibility(.struct("PublicWrapper")) {
self.assertNotRedundantPublicAccessibility(.varInstance("wrappedValue"))
self.assertNotRedundantPublicAccessibility(.functionConstructor("init(wrappedValue:)"))
}

assertNotRedundantPublicAccessibility(.struct("PublicWrappedProperty")) {
self.assertNotRedundantPublicAccessibility(.varInstance("wrappedProperty"))
}
}
}

0 comments on commit f427a54

Please sign in to comment.