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

Index store does not relate objc optional protocol method implemented in subclass

    XMLWordPrintable

    Details

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

      Swift 5.3.1

      Description

      Given the following code:

      import Foundation
      
      open class Baseclass: NSObject, FileManagerDelegate {
          public func fileManager(_ fileManager: FileManager, shouldRemoveItemAt URL: URL) -> Bool {
              false
          }
      }
      
      public class Subclass: Baseclass {
          func fileManager(_ fileManager: FileManager, shouldRemoveItemAtPath path: String) -> Bool {
              false
          }
      }
      

      The index store does not relate the method implemented in the subclass to the protocol declaration, although it does so for the method implemented in the baseclass. From the perspective of detecting unused code, it's not possible to identify that fileManager(_:shouldRemoveItemAtPath:) is an implementation of the protocol method.

      Method in subclass:

      10:10 | instance-method/Swift | fileManager(_:shouldRemoveItemAtPath:) | c:@M@swift_ide_test@objc(cs)Subclass(im)fileManager:shouldRemoveItemAtPath: | Def,Dyn,RelChild | rel: 1
        RelChild | class/Swift | Subclass | c:@M@swift_ide_test@objc(cs)Subclass
      

      Method in baseclass, note the extra `RelOver`:

      9:14 | instance-method/Swift | fileManager(_:shouldRemoveItemAt:) | c:@M@swift_ide_test@objc(cs)Baseclass(im)fileManager:shouldRemoveItemAtURL: | Impl,RelOver,RelCont | rel: 2
        RelOver | instance-method/Swift | fileManager(_:shouldRemoveItemAt:) | c:objc(pl)NSFileManagerDelegate(im)fileManager:shouldRemoveItemAtURL:
        RelCont | class/Swift | Subclass | c:@M@swift_ide_test@objc(cs)Subclass
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            Leitch Ian Leitch
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: