Skip to content

Commit

Permalink
Declarations referenced from a public @inlinable function must also b…
Browse files Browse the repository at this point in the history
…e public, closes #690
  • Loading branch information
ileitch committed Dec 19, 2023
1 parent f427a54 commit f5608a4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- `--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.
- Fix redundant public accessibility analysis false-positive for declarations referenced from a public `@inlinable` function.

## 2.17.1 (2023-12-04)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ final class RedundantExplicitPublicAccessibilityMarker: SourceGraphMutator {
return $0.parent
} else if decl.attributes.contains("propertyWrapper") {
return $0.parent
} else if let parent = $0.parent, parent.attributes.contains("inlinable") {
// Declarations referenced within a public @inlinable function must either be
// public or @useableFromInline.
return parent
}

return nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ Task {
// Property wrappers

_ = PublicWrappedProperty().wrappedProperty

// Inline

inlinableFunction()
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import Foundation

public class ClassReferencedFromPublicInlinableFunction {}

@usableFromInline
class ClassReferencedFromPublicInlinableFunction_UsableFromInline {}

@inlinable
public func inlinableFunction() {
_ = ClassReferencedFromPublicInlinableFunction.self
_ = ClassReferencedFromPublicInlinableFunction_UsableFromInline.self
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,4 +272,11 @@ class RedundantPublicAccessibilityTest: SourceGraphTestCase {
self.assertNotRedundantPublicAccessibility(.varInstance("wrappedProperty"))
}
}

func testPublicInlinableFunction() {
Self.index()

assertNotRedundantPublicAccessibility(.class("ClassReferencedFromPublicInlinableFunction"))
assertNotRedundantPublicAccessibility(.class("ClassReferencedFromPublicInlinableFunction_UsableFromInline"))
}
}

0 comments on commit f5608a4

Please sign in to comment.