Uploaded image for project: 'Swift'
  1. Swift
  2. SR-13766

Index store does not correctly relate variable type

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Component/s: Source Tooling
    • Labels:
      None
    • Environment:

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

      Description

      class MyClass1 {}
      
      public class MyClass2 {
          var someVar: MyClass1?
      }
      

      The index store contains an occurrence for `MyClass1` with a `reference` role, however said occurrence does not have any associated relations that tie it to `someVar`. The occurrence is therefore "dangling" or "toplevel", however you want to call it.

      The full dependency graph is as follows:
       

      Declaration(class, 'MyClass1', explicit, internal, [], 's:17RetentionFixtures8MyClass1C', testClassRetainedByUnusedInstanceVariable.swift:3:7)
      ··Declaration(function.constructor, 'init()', explicit, internal, [], 's:17RetentionFixtures8MyClass1CACycfc', testClassRetainedByUnusedInstanceVariable.swift:3:7)
      
      Reference(class, 'MyClass1', 's:17RetentionFixtures8MyClass1C', nil, testClassRetainedByUnusedInstanceVariable.swift:6:18)
      
      Declaration(class, 'MyClass2', explicit, public, [public], 's:17RetentionFixtures8MyClass2C', testClassRetainedByUnusedInstanceVariable.swift:5:14)
      ··Declaration(var.instance, 'someVar', explicit, internal, [], 's:17RetentionFixtures8MyClass2C7someVarAA0C6Class1CSgvp', testClassRetainedByUnusedInstanceVariable.swift:6:9)
      ··Declaration(function.constructor, 'init()', explicit, internal, [], 's:17RetentionFixtures8MyClass2CACycfc', testClassRetainedByUnusedInstanceVariable.swift:5:14)
      
      Declaration(function.accessor.getter, 'getter:someVar', explicit, internal, [], 's:17RetentionFixtures8MyClass2C7someVarAA0C6Class1CSgvg', testClassRetainedByUnusedInstanceVariable.swift:6:9)
      ··Reference(var.instance, 'someVar', 's:17RetentionFixtures8MyClass2C7someVarAA0C6Class1CSgvp', nil, testClassRetainedByUnusedInstanceVariable.swift:6:9)
      
      Declaration(function.accessor.setter, 'setter:someVar', explicit, internal, [], 's:17RetentionFixtures8MyClass2C7someVarAA0C6Class1CSgvs', testClassRetainedByUnusedInstanceVariable.swift:6:9)
      ··Reference(var.instance, 'someVar', 's:17RetentionFixtures8MyClass2C7someVarAA0C6Class1CSgvp', nil, testClassRetainedByUnusedInstanceVariable.swift:6:9)
      

      I'm expecting the dependency graph for 'MyClass2' to be as follows:

      Declaration(class, 'MyClass2', explicit, public, [public], 's:17RetentionFixtures8MyClass2C', testClassRetainedByUnusedInstanceVariable.swift:5:14)
      ··Declaration(var.instance, 'someVar', explicit, internal, [], 's:17RetentionFixtures8MyClass2C7someVarAA0C6Class1CSgvp', testClassRetainedByUnusedInstanceVariable.swift:6:9)
      ····Reference(class, 'MyClass1', 's:17RetentionFixtures8MyClass1C', nil, testClassRetainedByUnusedInstanceVariable.swift:6:18)
      ··Declaration(function.constructor, 'init()', explicit, internal, [], 's:17RetentionFixtures8MyClass2CACycfc', testClassRetainedByUnusedInstanceVariable.swift:5:14)
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            Leitch Ian Leitch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: