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

Types are not disambiguated #1641

Open
skrtks opened this issue Aug 26, 2024 · 2 comments
Open

Types are not disambiguated #1641

skrtks opened this issue Aug 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@skrtks
Copy link

skrtks commented Aug 26, 2024

Swift version

swiftlang-6.0.0.6.8

Platform

macOS 14.6.1

Editor

VSCode

Does the issue reproduce with Swift 6?

Yes

Description

In the example below, the type of a is main.Int and the type of b is Swift.Int. LSP seems to ignore that the using the unqualified Int is ambiguous in this context.

class Int {}
let a = Int()
let b = 1 + 1

Steps to Reproduce

In VSCode, type hints provided by SK-LSP show the same type for both variables. When double clicking the type hint, the inserted type is ambiguous. A similar issue appears when invoking the extract expression refactoring. When we try to extract 1 + 1, the generated code looks like let extractedExpr: Int = 1 + 1.

Logging

No response

@skrtks skrtks added the bug Something isn't working label Aug 26, 2024
@skrtks
Copy link
Author

skrtks commented Aug 26, 2024

It looks like the underlying SK requests never return qualified types. I added the fully_qualified option some time ago so we could process qualified types from SK. However, this makes all types qualified which might not be very user friendly when showing type hints.

There is the FullyQualifiedTypesIfAmbiguous option in PrintOptions.h, but after some quick testing the behaviour seems a bit unexpected. In the example I posted it only disambiguates the user introduced type, and not Swift.Int

@ahoppen
Copy link
Member

ahoppen commented Aug 26, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants
@ahoppen @skrtks and others