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

Suggesting converting private to fileprivate to avoid inaccessible error #66

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

kadanes
Copy link

@kadanes kadanes commented Feb 9, 2021

Due to private level restriction, the following code causes verbose defined in LogLevel, to be inaccessible in Logger. At least it should be made fileprivate so the logger extension can access it if defined in the same file. The other option is a public protection level.

extension LogLevel {
    private static var verbose = LogLevel(rawValue: 0b00000000_00000000_00000001_00000000)
}

extension Logger {
    public func verboseMessage(_ message: @autoclosure @escaping () -> String) {
    	logMessage(message, with: .verbose)
    }

    public func verboseMessage(_ message: @escaping () -> String) {
    	logMessage(message, with: .verbose)
    }
}

Fixing inaccessibility caused due to marking `verbose` as private
@kadanes
Copy link
Author

kadanes commented Feb 10, 2021

I think even fileprivate is too strong. New LogLevel should have public access. You can read more about the issue here: Accessing fileprivate and private variables in extension and another class using swift 4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant