Xcode 10.2 beta 2 (10P91b) SourceKit: editor.open syntax tree contains extraneous duplicate declaration with conflicting USR

Originator:port001
Number:rdar://48148270 Date Originated:
Status: Resolved:
Product: Product Version:
Classification: Reproducible:
 
Xcode 10.2 beta 2 (10P91b) SourceKit: editor.open syntax tree contains extraneous duplicate declaration with conflicting USR

Summary:

The `source.request.editor.open` request with `key.enablesyntaxtree = 1` response returned by SourceKit in Xcode 10.2 beta2 (10P91b) returns an extraneous duplicate `function.method.class` declaration as a descendent of the wrong class, that conflicts with another declaration with the same USR in another class.


Steps to Reproduce:

Given the following code:

```
import Foundation

protocol MyProtocol: class {
    static func someMethod()
}

open class MyBase: MyProtocol {
    open class func someMethod() {}
}

class MyClass: MyBase {
    override static func someMethod() {}
}
```

Output for 10.2 beta 2 (10P91b): https://gist.github.com/ileitch/e3464d7d66232a87613455f5686de7b2
Output for 10.1 (10B61): https://gist.github.com/ileitch/ce4969f04bc9e14f5b9441aac270d32a

Since the raw output can be hard to follow, I will demonstrate the issue using a more succinct parsed format. Due to the 3000 character limit of the bug report description, the parsed format can be found at the top of each gist.

`MyClass` in the 10.2 output contains an extraneous `function.method.class` declaration with the USR 's:17RetentionFixtures6MyBaseC10someMethodyyFZ'. This extraneous declaration duplicates the correct declaration with the same USR in `MyBase`. Note that the declaration also has no `name` and the USR itself references `MyBase` instead of `MyClass`, giving weight to it being incorrectly placed. It looks to me that SourceKit is confused by the use of `open class func` in `MyBase` and `open static func` in `MyClass` (note: class/static).

This extraneous declaration causes issues since its USR conflicts with the correct declaration in `MyBase`.

Version/Build:

Xcode 10.2 beta2 (10P91b)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!