swiftlang/swift

[SR-7933] SourceKit double-counts escaping and autoclosure attributes

Aberta

#50.468 aberto em 8 de jun. de 2018

 (2 comentários) (0 reação) (0 responsável)Swift (10.719 forks)batch import
good first issueimprovement

Métricas do repositório

Stars
 (69.989 estrelas)
Métricas de merge de PR
 (Métricas PR pendentes)

Description

Previous ID SR-7933
Radar None
Original Reporter @natecook1000
Type Improvement
Votes 0
Component/s Source Tooling
Labels Improvement, StarterBug
Assignee None
Priority Medium

md5: 065c0c3c9adc792d7d7203c32bd04ee2

Issue Description:

The @escaping and @autoclosure attributes are mapped differently from other attributes. For example, given this source code:

func a(_ b: @escaping () -> Bool) {}
@discardableResult func b() -> Int { return 0 }
func c(_ b: @autoclosure () -> Bool) {}

SourceKit yields this syntax map (unrelated pieces elided):

{
  key.offset: 0,
  key.length: 125,
  key.diagnostic_stage: source.diagnostic.stage.swift.parse,
  key.syntaxmap: [
    ...,
    {
      key.kind: source.lang.swift.syntaxtype.attribute.id,
      key.offset: 12,
      key.length: 9
    },
    {
      key.kind: source.lang.swift.syntaxtype.attribute.builtin,
      key.offset: 13,
      key.length: 8
    },
    ...,
    {
      key.kind: source.lang.swift.syntaxtype.attribute.builtin,
      key.offset: 37,
      key.length: 18
    },
    ...,
    {
      key.kind: source.lang.swift.syntaxtype.attribute.id,
      key.offset: 97,
      key.length: 12
    },
    {
      key.kind: source.lang.swift.syntaxtype.attribute.builtin,
      key.offset: 98,
      key.length: 11
    },
    ...
  ]
}

The "source.lang.swift.syntaxtype.attribute.builtin" keys should have the offset and length of the "source.lang.swift.syntaxtype.attribute.id" keys, which in turn shouldn't be emitted.

Guia do colaborador