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

[SR-9205] SourceKit is misrepresenting nested operators #51695

Closed
swift-ci opened this issue Nov 7, 2018 · 3 comments
Closed

[SR-9205] SourceKit is misrepresenting nested operators #51695

swift-ci opened this issue Nov 7, 2018 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Nov 7, 2018

Previous ID SR-9205
Radar None
Original Reporter rockbruno (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Bug
Assignee rockbruno (JIRA)
Priority Medium

md5: f78d9f8248b8cfe12367c3dee95bad65

Issue Description:

Consider the following snippet with two ways of representing operators:

class A {
    init(){}
}

func +(lhs: A, rhs: A) -> A {
    return lhs
}

class B {
    init() {}

    func foo() {
        let a = A()
        let b = a + a
        let c = B()
        let d = c - c
    }

    public static func -(lhs: B, rhs: B) -> B {
        return lhs
    }
}

If you run that through swift-ide-test, all references to + and - are correctly fetched:

5:6 | function/infix-operator/Swift | +(_:_:) | ... | Def
13:19 | function/infix-operator/Swift | +(_:_:) | ... | Ref
15:19 | static-method/infix-operator/Swift | -(_:_:) | ... | Ref
18:24 | static-method/infix-operator/Swift | -(_:_:) | ... | Def

But if you run the same snippet with SourceKit, the nested operator - is treated as a regular static method instead of an operator:

key.kind: source.lang.swift.decl.function.method.static,
key.name: "-(_:_:)",
key.line: 18,
key.column: 24,

key.kind: source.lang.swift.ref.function.method.static,
key.name: "-(_:_:)",
key.line: 15,
key.column: 19
@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 7, 2018

Comment by Bruno Rocha (JIRA)

Ah, seems that the issue is simply that the subkind isn't being checked in static functions: https://github.com/apple/swift/blob/master/tools/SourceKit/lib/SwiftLang/SwiftLangSupport.cpp#L561

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 8, 2018

Comment by Bruno Rocha (JIRA)

#20427

@swift-ci
Copy link
Collaborator Author

swift-ci commented Dec 3, 2018

Comment by Bruno Rocha (JIRA)

Merged.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

1 participant