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-13930] Index store does not relate objc optional protocol method implemented in subclass #56327

Open
swift-ci opened this issue Dec 3, 2020 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. class Feature → type declarations: Class declarations conformances Feature → protocol: protocol conformances declarations Feature: declarations indexing Area → source tooling: AST indexing inheritance Feature → type declarations → class: Subclassing and inheritance of class members optional protocol requirements Feature → protocol: optional protocol requirements protocol Feature → type declarations: Protocol declarations source tooling Area: IDE support, SourceKit, and other source tooling swift 5.9 unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Dec 3, 2020

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
@swift-ci
Copy link
Collaborator Author

swift-ci commented Dec 3, 2020

Comment by Ian Leitch (JIRA)

/cc @benlangmuir

@benlangmuir
Copy link
Member

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@keith
Copy link
Collaborator

keith commented May 26, 2023

seems to still be the case at ed3555a

@AnthonyLatsis AnthonyLatsis added source tooling Area: IDE support, SourceKit, and other source tooling swift 5.9 unexpected behavior Bug: Unexpected behavior or incorrect output indexing Area → source tooling: AST indexing conformances Feature → protocol: protocol conformances optional protocol requirements Feature → protocol: optional protocol requirements protocol Feature → type declarations: Protocol declarations declarations Feature: declarations inheritance Feature → type declarations → class: Subclassing and inheritance of class members class Feature → type declarations: Class declarations labels May 27, 2023
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. class Feature → type declarations: Class declarations conformances Feature → protocol: protocol conformances declarations Feature: declarations indexing Area → source tooling: AST indexing inheritance Feature → type declarations → class: Subclassing and inheritance of class members optional protocol requirements Feature → protocol: optional protocol requirements protocol Feature → type declarations: Protocol declarations source tooling Area: IDE support, SourceKit, and other source tooling swift 5.9 unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

No branches or pull requests

4 participants