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-13768] Index store does not relate constructor via literal notation #56165

Open
swift-ci opened this issue Oct 22, 2020 · 3 comments
Open
Labels
Array Area → standard library: The `Array` type bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. call expressions Feature → expressions: Call expressions declarations Feature: declarations expressions Feature: expressions indexing Area → source tooling: AST indexing init Feature → declarations: Initializers source tooling Area: IDE support, SourceKit, and other source tooling sugared types Feature: sugared types, e.g. 'Int?' or '[Int]' swift 5.9 types Feature: types unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@swift-ci
Copy link
Contributor

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)
@swift-ci
Copy link
Contributor Author

Comment by Ian Leitch (JIRA)

/cc @benlangmuir

@benlangmuir
Copy link
Contributor

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@keith keith added the indexing Area → source tooling: AST indexing label May 26, 2023
@keith
Copy link
Member

keith commented May 26, 2023

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

@AnthonyLatsis AnthonyLatsis added source tooling Area: IDE support, SourceKit, and other source tooling unexpected behavior Bug: Unexpected behavior or incorrect output sugared types Feature: sugared types, e.g. 'Int?' or '[Int]' expressions Feature: expressions swift 5.9 init Feature → declarations: Initializers declarations Feature: declarations types Feature: types call expressions Feature → expressions: Call expressions Array Area → standard library: The `Array` type labels May 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Array Area → standard library: The `Array` type bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. call expressions Feature → expressions: Call expressions declarations Feature: declarations expressions Feature: expressions indexing Area → source tooling: AST indexing init Feature → declarations: Initializers source tooling Area: IDE support, SourceKit, and other source tooling sugared types Feature: sugared types, e.g. 'Int?' or '[Int]' swift 5.9 types Feature: types unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

No branches or pull requests

4 participants