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-13769] Index store does not correctly relate variable getters with variable #56166

Closed
swift-ci opened this issue Oct 22, 2020 · 3 comments
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-13769
Radar None
Original Reporter Leitch (JIRA User)
Type Bug
Status Closed
Resolution Invalid
Environment

Apple Swift version 5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8)
Target: x86_64-apple-darwin19.6.0

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

md5: ef45a7c69d46745a6c3303b4c44b9154

Issue Description:

Given the following code:

class MyClass {
    var description: String {
        return "MyClass(\(descriptionParts.joined(separator: ", ")))"
    }

    var descriptionParts: [String] {
        return []
    }
}

The index store does not relate the `description` and `descriptionParts` getters with the actual variables, they instead have no relation. This is an issue since it's no longer possible to associate the body of the getter with the variable itself.

The following dependency graph highlights the issue:

Declaration(class, 'MyClass', explicit, internal, [], 's:17RetentionFixtures7MyClassC', testNonReferencedMethod.swift:3:7)
··Declaration(var.instance, 'description', explicit, internal, [], 's:17RetentionFixtures7MyClassC11descriptionSSvp', testNonReferencedMethod.swift:4:9)
··Declaration(var.instance, 'descriptionParts', explicit, internal, [], 's:17RetentionFixtures7MyClassC16descriptionPartsSaySSGvp', testNonReferencedMethod.swift:8:9)
··Declaration(function.constructor, 'init()', explicit, internal, [], 's:17RetentionFixtures7MyClassCACycfc', testNonReferencedMethod.swift:3:7)

Declaration(function.accessor.getter, 'getter:description', explicit, internal, [], 's:17RetentionFixtures7MyClassC11descriptionSSvg', testNonReferencedMethod.swift:4:29)
··Reference(var.instance, 'description', 's:17RetentionFixtures7MyClassC11descriptionSSvp', nil, testNonReferencedMethod.swift:4:29)
··Reference(function.accessor.getter, 'getter:descriptionParts', 's:17RetentionFixtures7MyClassC16descriptionPartsSaySSGvg', nil, testNonReferencedMethod.swift:5:27)
··Reference(var.instance, 'descriptionParts', 's:17RetentionFixtures7MyClassC16descriptionPartsSaySSGvp', nil, testNonReferencedMethod.swift:5:27)
··Reference(function.method.instance, 'joined(separator:)', 's:SKsSS7ElementRtzrlE6joined9separatorS2S_tF', nil, testNonReferencedMethod.swift:5:44)

Declaration(function.accessor.getter, 'getter:descriptionParts', explicit, internal, [], 's:17RetentionFixtures7MyClassC16descriptionPartsSaySSGvg', testNonReferencedMethod.swift:8:36)
··Reference(var.instance, 'descriptionParts', 's:17RetentionFixtures7MyClassC16descriptionPartsSaySSGvp', nil, testNonReferencedMethod.swift:8:36)

Both toplevel `function.accessor.getter` declarations should instead be related as direct children of their respective variables.

@swift-ci
Copy link
Collaborator Author

Comment by Ian Leitch (JIRA)

/cc @benlangmuir

@benlangmuir
Copy link
Member

They are already related as children of their properties. They have both child and accessor relations. Are you perhaps misinterpreting the direction of the relationship? It's "getter:description is a child of description".

2:9 | instance-property/Swift | description | <usr> | Def,RelChild | rel: 1
  RelChild | class/Swift | MyClass | s:14swift_ide_test7MyClassC
2:29 | instance-method/acc-get/Swift | getter:description | <usr> | Def,Dyn,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | instance-property/Swift | description | <usr>
...
6:9 | instance-property/Swift | descriptionParts | <usr> | Def,RelChild | rel: 1
  RelChild | class/Swift | MyClass | <usr>
6:36 | instance-method/acc-get/Swift | getter:descriptionParts | <usr> | Def,Dyn,RelChild,RelAcc | rel: 1
  RelChild,RelAcc | instance-property/Swift | descriptionParts | <usr>
6:28 | struct/Swift | String | s:SS | Ref | rel: 0

@swift-ci
Copy link
Collaborator Author

Comment by Ian Leitch (JIRA)

Sorry for the noise, this was indeed an issue in my code.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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.
Projects
None yet
Development

No branches or pull requests

2 participants