Skip to content

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

Open
@swift-ci

Description

@swift-ci
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.classFeature → type declarations: Class declarationsconformancesFeature → protocol: protocol conformancesdeclarationsFeature: declarationsindexingArea → source tooling: AST indexinginheritanceFeature → type declarations → class: Subclassing and inheritance of class membersoptional protocol requirementsFeature → protocol: optional protocol requirementsprotocolFeature → type declarations: Protocol declarationssource toolingArea: IDE support, SourceKit, and other source toolingswift 5.9unexpected behaviorBug: Unexpected behavior or incorrect output

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions