Uploaded image for project: 'Swift'
  1. Swift
  2. SR-8617

Explicit types in pattern matching are not being indexed

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Done
    • Component/s: Source Tooling
    • Labels:
      None
    • Environment:

      SourceKit from Xcode 9.4.1 / Xcode 10 beta 6

      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`.

       

        Attachments

          Activity

            People

            • Assignee:
              rockbruno Bruno Rocha
              Reporter:
              rockbruno Bruno Rocha
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: