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
kmahar opened this issue Apr 2, 2019 · 5 comments

Comments

Projects
None yet
3 participants
@kmahar
Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Author

commented Apr 23, 2019

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

@jpsim

This comment has been minimized.

Copy link
Collaborator

commented Apr 29, 2019

@skagedal

This comment has been minimized.

Copy link

commented Apr 29, 2019

Works great, thanks @marcelofabri and @jpsim!

@kmahar

This comment has been minimized.

Copy link
Author

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
You can’t perform that action at this time.