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-14181] Index store does not relate constructor referenced via Self #56559

Closed
swift-ci opened this issue Feb 10, 2021 · 3 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. duplicate Resolution: Duplicates another issue expressions Feature: expressions indexing Area → source tooling: AST indexing Self in struct & enum Feature → types: The 'Self' type in structures and enumerations source tooling Area: IDE support, SourceKit, and other source tooling swift 5.4 unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Feb 10, 2021

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

Swift 5.3 & 5.4 beta

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

md5: 14bd45e97ccd316281a8cb702253758c

Issue Description:

Given the following code:

struct MyStruct {
    static let instance = Self(someVar: 123)
    let someVar: Int

    init(someVar: Int) {
        self.someVar = someVar
    }
}

The index store does not relate the constructor at all. For the purposes of identifying unused code, it's not possible to determine that the constructor is in use. It's debatable which definition should hold the constructor relation. Either the struct or the property would suffice, though the implicit property setter would be my preference.

1:8 | struct/Swift | MyStruct | s:14swift_ide_test8MyStructV | Def | rel: 0
2:16 | static-property/Swift | instance | s:14swift_ide_test8MyStructV8instanceACvpZ | Def,RelChild | rel: 1
  RelChild | struct/Swift | MyStruct | s:14swift_ide_test8MyStructV
2:16 | static-method/acc-get/Swift | getter:instance | s:14swift_ide_test8MyStructV8instanceACvgZ | Def,Impl,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | static-property/Swift | instance | s:14swift_ide_test8MyStructV8instanceACvpZ
2:16 | static-method/acc-set/Swift | setter:instance | s:14swift_ide_test8MyStructV8instanceACvsZ | Def,Impl,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | static-property/Swift | instance | s:14swift_ide_test8MyStructV8instanceACvpZ
3:9 | instance-property/Swift | someVar | s:14swift_ide_test8MyStructV7someVarSivp | Def,RelChild | rel: 1
  RelChild | struct/Swift | MyStruct | s:14swift_ide_test8MyStructV
3:9 | instance-method/acc-get/Swift | getter:someVar | s:14swift_ide_test8MyStructV7someVarSivg | Def,Impl,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | instance-property/Swift | someVar | s:14swift_ide_test8MyStructV7someVarSivp
3:9 | instance-method/acc-set/Swift | setter:someVar | s:14swift_ide_test8MyStructV7someVarSivs | Def,Impl,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | instance-property/Swift | someVar | s:14swift_ide_test8MyStructV7someVarSivp
3:18 | struct/Swift | Int | s:Si | Ref | rel: 0
5:5 | constructor/Swift | init(someVar:) | s:14swift_ide_test8MyStructV7someVarACSi_tcfc | Def,RelChild | rel: 1
  RelChild | struct/Swift | MyStruct | s:14swift_ide_test8MyStructV
5:10 | param/Swift | someVar | s:14swift_ide_test8MyStructV7someVarACSi_tcfcADL_Sivp | Def,RelChild | rel: 1
  RelChild | constructor/Swift | init(someVar:) | s:14swift_ide_test8MyStructV7someVarACSi_tcfc
5:10 | function/acc-get/Swift | getter:someVar | s:14swift_ide_test8MyStructV7someVarACSi_tcfcADL_Sivg | Def,Impl,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | param/Swift | someVar | s:14swift_ide_test8MyStructV7someVarACSi_tcfcADL_Sivp
5:10 | function/acc-set/Swift | setter:someVar | s:14swift_ide_test8MyStructV7someVarACSi_tcfcADL_Sivs | Def,Impl,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | param/Swift | someVar | s:14swift_ide_test8MyStructV7someVarACSi_tcfcADL_Sivp
5:19 | struct/Swift | Int | s:Si | Ref,RelCont | rel: 1
  RelCont | constructor/Swift | init(someVar:) | s:14swift_ide_test8MyStructV7someVarACSi_tcfc
6:14 | instance-property/Swift | someVar | s:14swift_ide_test8MyStructV7someVarSivp | Ref,Writ,RelCont | rel: 1
  RelCont | constructor/Swift | init(someVar:) | s:14swift_ide_test8MyStructV7someVarACSi_tcfc
6:14 | instance-method/acc-set/Swift | setter:someVar | s:14swift_ide_test8MyStructV7someVarSivs | Ref,Call,Impl,RelRec,RelCall,RelCont | rel: 2
  RelCall,RelCont | constructor/Swift | init(someVar:) | s:14swift_ide_test8MyStructV7someVarACSi_tcfc
  RelRec | struct/Swift | MyStruct | s:14swift_ide_test8MyStructV
6:24 | param/Swift | someVar | s:14swift_ide_test8MyStructV7someVarACSi_tcfcADL_Sivp | Ref,Read,RelCont | rel: 1
  RelCont | constructor/Swift | init(someVar:) | s:14swift_ide_test8MyStructV7someVarACSi_tcfc
6:24 | function/acc-get/Swift | getter:someVar | s:14swift_ide_test8MyStructV7someVarACSi_tcfcADL_Sivg | Ref,Call,Impl,RelCall,RelCont | rel: 1
  RelCall,RelCont | constructor/Swift | init(someVar:) | s:14swift_ide_test8MyStructV7someVarACSi_tcfc
@swift-ci
Copy link
Contributor Author

Comment by Ian Leitch (JIRA)

/cc @benlangmuir

@typesanitizer
Copy link

@swift-ci create

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

keith commented May 26, 2023

dup of #64686 which is fixed on main and submitted to 5.9 for a cherry pick

@keith keith closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2023
@keith keith added the indexing Area → source tooling: AST indexing label May 26, 2023
@AnthonyLatsis AnthonyLatsis added swift 5.4 expressions Feature: expressions init Feature → declarations: Initializers Self in struct & enum Feature → types: The 'Self' type in structures and enumerations declarations Feature: declarations call expressions Feature → expressions: Call expressions source tooling Area: IDE support, SourceKit, and other source tooling duplicate Resolution: Duplicates another issue unexpected behavior Bug: Unexpected behavior or incorrect output and removed init Feature → declarations: Initializers declarations Feature: declarations call expressions Feature → expressions: Call expressions labels May 30, 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. duplicate Resolution: Duplicates another issue expressions Feature: expressions indexing Area → source tooling: AST indexing Self in struct & enum Feature → types: The 'Self' type in structures and enumerations source tooling Area: IDE support, SourceKit, and other source tooling swift 5.4 unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

No branches or pull requests

4 participants