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

Exported symbols are duplicated in completion list #74076

Open
adam-fowler opened this issue May 14, 2024 · 2 comments
Open

Exported symbols are duplicated in completion list #74076

adam-fowler opened this issue May 14, 2024 · 2 comments
Labels
code completion Area → source tooling: code completion

Comments

@adam-fowler
Copy link

adam-fowler commented May 14, 2024

Swift version

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

Platform

arm64-apple-macosx14.0

Editor

VSCode

Does the issue reproduce with Swift 6?

Yes

Description

If I export a symbol from a library to include it in the public symbols of another library then SourceKit-LSP considers these to be separate symbols and will duplicate them in completion lists

Steps to Reproduce

  • Create a package with a library called Duplicate using SwiftPM
  • Add to source of package @_exported import class Foundation.JSONDecoder
  • Create another target that is dependent on the original library target
  • Add the following lines
import Foundation
import Duplicate
  • Compile
  • Now when I type JSON into the file I get two completion entries for JSONDecoder.

Logging

No response

@adam-fowler adam-fowler added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label May 14, 2024
@ahoppen
Copy link
Contributor

ahoppen commented May 14, 2024

Synced to Apple’s issue tracker as rdar://128057021

@ahoppen
Copy link
Contributor

ahoppen commented Jun 1, 2024

Reduced to a sourcekitd test case. Moving to the apple/swift repo because that’s where sourcekitd lives.

// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %swift-frontend -emit-module %t/Lib.swift -o %t/Modules/Lib.swiftmodule
// RUN: %swift-frontend -emit-module %t/Exporter.swift -o %t/Modules/Exporter.swiftmodule -I %t/Modules 
// RUN: %swift-ide-test -code-completion -source-filename %t/Client.swift -I %t/Modules -code-completion-token COMPLETE | %FileCheck %s

//--- Lib.swift

public class MyClass {
  public lazy var lazyValue: Bool = true
}

//--- Exporter.swift

@_exported import class Lib.MyClass

//--- Client.swift

import Lib
import Exporter

#^COMPLETE^#

// CHECK: Decl[Class]/OtherModule[Lib]:       MyClass[#MyClass#]; name=MyClass
// CHECK-NOT: MyClass

@ahoppen ahoppen removed the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Jun 1, 2024
@ahoppen ahoppen transferred this issue from apple/sourcekit-lsp Jun 1, 2024
@ahoppen ahoppen added the code completion Area → source tooling: code completion label Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code completion Area → source tooling: code completion
Projects
None yet
Development

No branches or pull requests

2 participants