Lower ACL than Parent

Ensure declarations have a lower access control level than their enclosing parent

  • Identifier: lower_acl_than_parent
  • Enabled by default: No
  • Supports autocorrection: Yes
  • Kind: lint
  • Analyzer rule: No
  • Minimum Swift compiler version: 5.0.0
  • Default configuration:
    KeyValue
    severity warning

Non Triggering Examples

public struct Foo { public func bar() {} }
internal struct Foo { func bar() {} }
struct Foo { func bar() {} }
struct Foo { internal func bar() {} }
open class Foo { public func bar() {} }
open class Foo { open func bar() {} }
fileprivate struct Foo { private func bar() {} }
private struct Foo { private func bar(id: String) }
extension Foo { public func bar() {} }
private struct Foo { fileprivate func bar() {} }
private func foo(id: String) {}
private class Foo { func bar() {} }
public extension Foo { struct Bar { public func baz() {} }}
public extension Foo { struct Bar { internal func baz() {} }}
internal extension Foo { struct Bar { internal func baz() {} }}
extension Foo { struct Bar { internal func baz() {} }}

Triggering Examples

struct Foo { public func bar() {} }
enum Foo { public func bar() {} }
public class Foo { open func bar() }
class Foo { public private(set) var bar: String? }
private struct Foo { public func bar() {} }
private class Foo { public func bar() {} }
private actor Foo { public func bar() {} }
fileprivate struct Foo { public func bar() {} }
class Foo { public func bar() {} }
actor Foo { public func bar() {} }
private struct Foo { internal func bar() {} }
fileprivate struct Foo { internal func bar() {} }
extension Foo { struct Bar { public func baz() {} }}
internal extension Foo { struct Bar { public func baz() {} }}
private extension Foo { struct Bar { public func baz() {} }}
fileprivate extension Foo { struct Bar { public func baz() {} }}
private extension Foo { struct Bar { internal func baz() {} }}
fileprivate extension Foo { struct Bar { internal func baz() {} }}
public extension Foo { struct Bar { struct Baz { public func qux() {} }}}
final class Foo { public func bar() {} }