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-8617] Explicit types in pattern matching are not being indexed #51132

Closed
swift-ci opened this issue Aug 23, 2018 · 2 comments
Closed

[SR-8617] Explicit types in pattern matching are not being indexed #51132

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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8617
Radar None
Original Reporter rockbruno (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

SourceKit from Xcode 9.4.1 / Xcode 10 beta 6

Additional Detail from JIRA
Votes 0
Component/s Source Tooling
Labels Bug
Assignee rockbruno (JIRA)
Priority Medium

md5: 37fd5b11b99ef22e2a2d0a654b5305f4

Issue Description:

When explicitly declaring an enum case's type in pattern matching, swift-ide-test will correctly index the enum case (.bar), but not the type itself (Foo).

enum Foo {
    case bar
}

func match() {
    let type: Foo = .bar
    if case Foo.bar = type {
        print("matched")
    }
}
1:6 | enum/Swift | Foo | s:14swift_ide_test3FooO | Def | rel: 0
2:10 | enumerator/Swift | bar | s:14swift_ide_test3FooO3baryA2CmF | Def,RelChild | rel: 1
  RelChild | enum/Swift | Foo | s:14swift_ide_test3FooO
5:6 | function/Swift | match() | s:14swift_ide_test5matchyyF | Def | rel: 0
6:15 | enum/Swift | Foo | s:14swift_ide_test3FooO | Ref,RelCont | rel: 1
  RelCont | function/Swift | match() | s:14swift_ide_test5matchyyF
6:22 | enumerator/Swift | bar | s:14swift_ide_test3FooO3baryA2CmF | Ref,RelCont | rel: 1
  RelCont | function/Swift | match() | s:14swift_ide_test5matchyyF
7:17 | enumerator/Swift | bar | s:14swift_ide_test3FooO3baryA2CmF | Ref,RelCont | rel: 1
  RelCont | function/Swift | match() | s:14swift_ide_test5matchyyF
8:9 | function/Swift | print(_:separator:terminator:) | s:s5print_9separator10terminatoryypd_S2StF | Ref,Call,RelCall,RelCont | rel: 1
  RelCall,RelCont | function/Swift | match() | s:14swift_ide_test5matchyyF

Although this example is uncommon, this can happen in real projects when referencing nested enum types or inheritable types such as custom error types that inherit from `Error`.

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 5, 2018

Comment by Bruno Rocha (JIRA)

#20324

@swift-ci
Copy link
Collaborator Author

swift-ci commented Nov 7, 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