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-7093] Index does not include reference to constructor of class/struct with generic types #49641

Closed
swift-ci opened this issue Feb 28, 2018 · 5 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. call expressions Feature → expressions: Call expressions declarations Feature: declarations duplicate Resolution: Duplicates another issue expressions Feature: expressions generics Feature: generic declarations and types indexing Area → source tooling: AST indexing init Feature → declarations: Initializers source tooling Area: IDE support, SourceKit, and other source tooling swift 4.0 type declarations Feature → declarations: Type declarations unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Feb 28, 2018

Previous ID SR-7093
Radar rdar://problem/70955529
Original Reporter Leitch (JIRA User)
Type Bug
Environment

Using SourceKitten to perform the SourceKit request.

Xcode 9.2
Build version 9C40b

macOS 10.13.3

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

md5: f31c557a78a7016c21e6bf633e9bada7

Issue Description:

Given the following code:

class ClassA<T> {
    init(someVar: Int = 0) {}
}

class ClassB {
    private let classA: ClassA<String>

    init() {
        classA = ClassA<String>()
    }
}

A source.request.indexsource response does not include a source.lang.swift.ref.function.constructor reference for ClassA<String>() to the declaration init(someVar:). The constructor has the USR s:4test6ClassACACyxGSi7someVar_tcfc and it is not referenced anywhere in the index.

This issue appears to only affect classes with generic types. If I remove the generic type from ClassA, the ClassB constructor declaration will contain a reference to init(someVar:).

Full index response is here: https://gist.github.com/ileitch/2b6b08ab247d712da752c5c24b5fca85

/cc @nkcsgexi @benlangmuir

@swift-ci
Copy link
Contributor Author

swift-ci commented Nov 1, 2020

Comment by Ian Leitch (JIRA)

@benlangmuir This is also an issue with the index store in Swift 5.3.1.

@benlangmuir
Copy link
Contributor

Also reproduces with indexing while building

$ swift-ide-test --print-indexed-symbols --source-filename /tmp/t.swift
...
9:18 | class/Swift | ClassA | s:14swift_ide_test6ClassAC | Ref,RelCont | rel: 1
  RelCont | constructor/Swift | init() | s:14swift_ide_test6ClassBCACycfc
9:25 | struct/Swift | String | s:SS | Ref,RelCont | rel: 1
  RelCont | constructor/Swift | init() | s:14swift_ide_test6ClassBCACycfc

No reference to the initializer.

@benlangmuir
Copy link
Contributor

@swift-ci create

@swift-ci
Copy link
Contributor Author

swift-ci commented Mar 5, 2021

Comment by Ian Leitch (JIRA)

This also affects generic structs.

@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

dup of #54532, fixed on main, hopefully will make 5.9

@keith keith closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2023
@AnthonyLatsis AnthonyLatsis added source tooling Area: IDE support, SourceKit, and other source tooling unexpected behavior Bug: Unexpected behavior or incorrect output duplicate Resolution: Duplicates another issue swift 4.0 generics Feature: generic declarations and types init Feature → declarations: Initializers declarations Feature: declarations expressions Feature: expressions call expressions Feature → expressions: Call expressions type declarations Feature → declarations: Type declarations labels May 27, 2023
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. call expressions Feature → expressions: Call expressions declarations Feature: declarations duplicate Resolution: Duplicates another issue expressions Feature: expressions generics Feature: generic declarations and types indexing Area → source tooling: AST indexing init Feature → declarations: Initializers source tooling Area: IDE support, SourceKit, and other source tooling swift 4.0 type declarations Feature → declarations: Type declarations unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

No branches or pull requests

4 participants