Skip to content

[CodeCompletion] Do not include decl in own (string interp) initializer #34548

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

Merged

Conversation

bnbarham
Copy link
Contributor

@bnbarham bnbarham commented Nov 3, 2020

Strings are a single token, so the previous check would treat
completions inside string interpolations as being outside of the
initializer.

Grab the end of the token from the Lexer, but wrap in a context check to
avoid performing that for every declaration found in the lookup.

Resolves rdar://70833348

@bnbarham bnbarham requested a review from rintaro November 3, 2020 00:26
@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 3, 2020

@swift-ci please test

@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 3, 2020

Just noticed I had left the types of the added tests as Int rather than String. Shouldn't matter but do you want me to fix that?

@swift-ci
Copy link
Contributor

swift-ci commented Nov 3, 2020

Build failed
Swift Test Linux Platform
Git Sha - 97d7e9d9c194644db41b9f1220b7e9e18b040471

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The context type shouldn't matter. So I'm OK with it.

But,

func foo(arg: Int = #^HERE^#) {}

I just noticed this suggests arg in Swift5.3, which is not OK. Does this (or your recent) change resolve it too? Could you add test cases for them?

@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 3, 2020

The context type shouldn't matter. So I'm OK with it.

But,

func foo(arg: Int = #^HERE^#) {}

I just noticed this suggests arg in Swift5.3, which is not OK. Does this (or your recent) change resolve it too? Could you add test cases for them?

The previous one should fix that case, but I can add it in this one. May as well fix the type while I'm at it as well. Thanks :)

Strings are a single token, so the previous check would treat
completions inside string interpolations as being outside of the
initializer.

Grab the end of the token from the Lexer, but wrap in a context check to
avoid performing that for every declaration found in the lookup.

Resolves rdar://70833348
Similar to 4cf7426 but for the case
when the completion is in a default argument expression rather than
initializer. Fixed to grab either the initializer or default argument if
there is one.
@bnbarham bnbarham force-pushed the completion-string-interp-init-70833348 branch from 97d7e9d to c3d1e34 Compare November 3, 2020 06:44
@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 3, 2020

Previous did not fix... it was only checking the initializer, not for a default argument. Added another commit to fix that one as well. Also enabled some disabled tests that should work now (have for a while I think). Let me know if you'd prefer it in a separate PR.

@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 3, 2020

@swift-ci please test

@swift-ci
Copy link
Contributor

swift-ci commented Nov 3, 2020

Build failed
Swift Test Linux Platform
Git Sha - c3d1e34

@bnbarham
Copy link
Contributor Author

bnbarham commented Nov 3, 2020

@swift-ci please test Linux platform

Copy link
Member

@rintaro rintaro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@bnbarham bnbarham merged commit 9532169 into swiftlang:main Nov 4, 2020
@bnbarham bnbarham deleted the completion-string-interp-init-70833348 branch November 4, 2020 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants