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_type_interface rule triggered in case let switches #2154

Closed
Hans92 opened this Issue Apr 13, 2018 · 4 comments

Comments

Projects
None yet
3 participants
@Hans92
Copy link

Hans92 commented Apr 13, 2018

Xcode 9.3 (9E145)
Swiflint 0.25.1

struct SomeError: Error { }
struct SomeError1: Error { }

let error: Error = Error()

switch error {
	case let error as SomeError:
		// some code
	case let error as SomeError1:
		// some code
}

On every case line I get an error:
"Explicit Type Interface Violation: Properties should have a type interface (explicit_type_interface)".
I can't add here error type. Swift doesn't get it.

I am not sure if this is a bug or I'm doing something wrong.

@marcelofabri

This comment has been minimized.

Copy link
Collaborator

marcelofabri commented Apr 13, 2018

Maybe we should ignore variables inside cases (source.lang.swift.stmt.case)?

This is the structure that SourceKit returns:

{
          "key.elements" : [
            {
              "key.kind" : "source.lang.swift.structure.elem.pattern",
              "key.length" : 23,
              "key.offset" : 164
            }
          ],
          "key.kind" : "source.lang.swift.stmt.case",
          "key.length" : 29,
          "key.namelength" : 0,
          "key.nameoffset" : 0,
          "key.offset" : 159,
          "key.substructure" : [
            {
              "key.kind" : "source.lang.swift.decl.var.local",
              "key.length" : 5,
              "key.name" : "error",
              "key.namelength" : 5,
              "key.nameoffset" : 168,
              "key.offset" : 168
            }
          ]
        }

@marcelofabri marcelofabri added the bug label Apr 13, 2018

@Hans92

This comment has been minimized.

Copy link
Author

Hans92 commented Apr 18, 2018

There is also a problem with [weak self] in closures.

@marcelofabri

This comment has been minimized.

Copy link
Collaborator

marcelofabri commented Apr 18, 2018

Feel free to send a PR!

@ppamorim

This comment has been minimized.

Copy link

ppamorim commented Jun 8, 2018

There is a error on case .failure(let error):, Swiftlint warns to set a type, but it is not possible.

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.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.