Skip to content

Commit

Permalink
Ignore array types if their Index is accessed
Browse files Browse the repository at this point in the history
  • Loading branch information
SimplyDanny committed May 7, 2022
1 parent f880b66 commit 4e14f96
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private final class SyntacticSugarRuleVisitor: SyntaxVisitor {
// Skip checks for 'self' or \T Dictionary<Key, Value>.self
if let parent = node.parent?.as(MemberAccessExprSyntax.self),
let lastToken = Array(parent.tokens).last?.tokenKind,
lastToken == .selfKeyword || lastToken == .identifier("Type") || lastToken == .identifier("none") {
[.selfKeyword, .identifier("Type"), .identifier("none"), .identifier("Index")].contains(lastToken) {
return
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ internal enum SyntacticSugarRuleExamples {
Example("let x: Foo.Optional<String>"),

Example("let x = case Optional<Any>.none = obj"),
Example("let a = Swift.Optional<String?>.none")
Example("let a = Swift.Optional<String?>.none"),
Example("func f() -> [Array<Int>.Index] { [Array<Int>.Index]() }", excludeFromDocumentation: true)
]

static let triggering = [
Expand Down

0 comments on commit 4e14f96

Please sign in to comment.