swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
66.99k stars 10.32k forks source link

Exported symbols are duplicated in completion list #74076

Open adam-fowler opened 2 months ago

adam-fowler commented 2 months ago

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

Logging

No response

ahoppen commented 2 months ago

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

ahoppen commented 1 month ago

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