swiftlang/swift

[SR-13930] Index store does not relate objc optional protocol method implemented in subclass

swift-ci opened this issue · 3 comments

Previous ID SR-13930
Radar rdar://problem/71941002
Original Reporter Leitch (JIRA User)
Type Bug
Environment

Swift 5.3.1

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

md5: b4e60253efa0e8c7ffa0ba78d8eff02f

Issue 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

Comment by Ian Leitch (JIRA)

/cc @benlangmuir

keith commented

seems to still be the case at ed3555a