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

Index store does not relate constructor via literal notation

    XMLWordPrintable

    Details

    • Type: Bug
    • 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

      Given the following code:

      public class MyClass {
          public func someMethod() {
              let title = [String](title: "Title").first
              print(title)
          }
      }
      
      extension Array where Element == String {
          init(title: String) {
              self = [title]
          }
      }
      

      The index store should contain a reference occurrence to the custom Array constructor. Specifically, the use of [String] literal notation is the problem here, as let title = Array(title: "Title") correctly relates the constructor.

      Full dependency graph is as follows:

      Declaration(class, 'MyClass', explicit, public, [public], 's:17RetentionFixtures7MyClassC', testCustomConstructorithLiteral.swift:3:14)
      ··Declaration(function.method.instance, 'someMethod()', explicit, public, [public], 's:17RetentionFixtures7MyClassC10someMethodyyF', testCustomConstructorithLiteral.swift:4:17)
      ····Reference(struct, 'String', 's:SS', nil, testCustomConstructorithLiteral.swift:5:22)
      ····Reference(function.accessor.getter, 'getter:first', 's:SlsE5first7ElementQzSgvg', nil, testCustomConstructorithLiteral.swift:5:46)
      ····Reference(var.instance, 'first', 's:SlsE5first7ElementQzSgvp', nil, testCustomConstructorithLiteral.swift:5:46)
      ····Reference(function.free, 'print(_:separator:terminator:)', 's:s5print_9separator10terminatoryypd_S2StF', nil, testCustomConstructorithLiteral.swift:6:9)
      ··Declaration(function.constructor, 'init()', explicit, internal, [], 's:17RetentionFixtures7MyClassCACycfc', testCustomConstructorithLiteral.swift:3:14)
      
      Reference(struct, 'String', 's:SS', nil, testCustomConstructorithLiteral.swift:10:34)
      
      Declaration(function.accessor.getter, 'getter:title', explicit, internal, [], 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfcABL_SSvg', testCustomConstructorithLiteral.swift:11:10)
      ··Reference(var.parameter, 'title', 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfcABL_SSvp', nil, testCustomConstructorithLiteral.swift:11:10)
      
      Declaration(function.accessor.setter, 'setter:title', explicit, internal, [], 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfcABL_SSvs', testCustomConstructorithLiteral.swift:11:10)
      ··Reference(var.parameter, 'title', 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfcABL_SSvp', nil, testCustomConstructorithLiteral.swift:11:10)
      
      Declaration(extension.struct, 'Array', explicit, internal, [], 's:e:s:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfc', testCustomConstructorithLiteral.swift:10:11)
      ··Reference(struct, 'Array', 's:Sa', nil, testCustomConstructorithLiteral.swift:10:11)
      ··Declaration(function.constructor, 'init(title:)', explicit, internal, [], 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfc', testCustomConstructorithLiteral.swift:11:5)
      ····Reference(struct, 'String', 's:SS', nil, testCustomConstructorithLiteral.swift:11:17)
      ····Reference(function.accessor.getter, 'getter:title', 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfcABL_SSvg', nil, testCustomConstructorithLiteral.swift:12:17)
      ····Reference(var.parameter, 'title', 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfcABL_SSvp', nil, testCustomConstructorithLiteral.swift:12:17)
      ····Declaration(var.parameter, 'title', explicit, internal, [], 's:Sa17RetentionFixturesSSRszlE5titleSaySSGSS_tcfcABL_SSvp', testCustomConstructorithLiteral.swift:11:10)
      

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated: