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

explicit_acl should not be triggered for extensions adding protocol conformance #2705

Closed
2 tasks done
kmahar opened this issue Apr 2, 2019 · 5 comments
Closed
2 tasks done

Comments

@kmahar
Copy link
Contributor

kmahar commented Apr 2, 2019

New Issue Checklist

Describe the bug

Swiftlint tells me that I need to add an access control level for an extension that adds protocol conformance. However, the Swift compiler won't allow me to do that -- when I try to build I get
error: 'public' modifier cannot be used with extensions that declare protocol conformances. (Note I get an equivalent error if I use any other ACL, private, internal, etc.)

This can be reproduced in a directory containing just the following two files:

lint.swift

public struct MyStruct {}
extension MyStruct: Equatable {}

.swiftlint.yml

opt_in_rules:
  - explicit_acl
Complete output when running SwiftLint, including the stack trace and command used
kaitlinmahar@kaitlin:~/lint-test$ swiftlint lint
Loading configuration from '.swiftlint.yml'
Linting Swift files at paths
Linting 'lint.swift' (1/1)
/Users/kaitlinmahar/lint-test/lint.swift:2:1: warning: Explicit ACL Violation: All declarations should specify Access Control Level keywords explicitly. (explicit_acl)
Done linting! Found 1 violation, 0 serious in 1 file.

If I change the file to:

public struct MyStruct {}
public extension MyStruct: Equatable {}

Swiftlint is satisfied --

kaitlinmahar@kaitlin:~/lint-test$ swiftlint lint
Loading configuration from '.swiftlint.yml'
Linting Swift files at paths
Linting 'lint.swift' (1/1)
Done linting! Found 0 violations, 0 serious in 1 file.

But the compiler is not:

kaitlinmahar@kaitlin:~/lint-test$ swift lint.swift
lint.swift:2:1: error: 'public' modifier cannot be used with extensions that declare protocol conformances
public extension MyStruct: Equatable {}
^~~~~~~

Environment

  • SwiftLint version (run swiftlint version to be sure)? 0.31.0
  • Installation method used (Homebrew, CocoaPods, building from source, etc)? Homebrew
  • Which Xcode version are you using (check xcode-select -p)? xcode-select version 2354. However, I'm using Swift 4.2 installed via swiftenv.
kaitlinmahar@kaitlin:~/lint-test$ swift --version
Apple Swift version 4.2 (swift-4.2-RELEASE)
Target: x86_64-apple-darwin18.2.0

I also switched to Swift 5.0 via swiftenv and tested, same results.

@skagedal
Copy link

skagedal commented Apr 6, 2019

This happens for me when I run SwiftLint inside of Xcode 10.2, and from command line when having Xcode 10.2 as the xcode-selected version. Not with Xcode 10.1.

@kmahar
Copy link
Contributor Author

kmahar commented Apr 23, 2019

thanks so much for fixing this! 🙂when should we expect a new release?

@jpsim
Copy link
Collaborator

jpsim commented Apr 29, 2019

New release is out: https://github.com/realm/SwiftLint/releases/tag/0.32.0

@skagedal
Copy link

Works great, thanks @marcelofabri and @jpsim!

@kmahar
Copy link
Contributor Author

kmahar commented Apr 29, 2019

awesome, thank you!!!!

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

No branches or pull requests

3 participants