swiftlang/swift

[SR-13768] Index store does not relate constructor via literal notation

swift-ci opened this issue · 3 comments

Previous ID SR-13768
Radar rdar://problem/70580253
Original Reporter Leitch (JIRA User)
Type Bug
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: d4b76e983a5cc88b174117153c157b83

Issue 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)

Comment by Ian Leitch (JIRA)

/cc @benlangmuir

keith commented

seems to still be the case at ed3555a potentially similar to #65597