Skip to content

[IDE] Ignore score kinds that represent implicit conversions when solving for code completion #63855

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Feb 23, 2023

Ignore conversion score increases during code completion to make sure we don't filter solutions that might start receiving the best score based on a choice of the code completion token.

@ahoppen ahoppen requested review from xedin and rintaro February 23, 2023 11:33
@ahoppen ahoppen requested a review from hborla as a code owner February 23, 2023 11:34
Type BaseTy;

/// The we were able to determine it, the decl that we are completing on.
Copy link
Contributor

Choose a reason for hiding this comment

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

Comment needs some adjustment :)


/// If the expression we are completing on statically refers to a metatype,
/// that is if it's something like 'MyType'. In such cases we want to offer
/// constructor call pattern completions and don't want to suggested
Copy link
Contributor

Choose a reason for hiding this comment

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

suggest*

@@ -927,6 +927,9 @@ enum ScoreKind: unsigned int {
/// A reference to an @unavailable declaration.
SK_Unavailable,
/// A reference to an async function in a synchronous context.
///
/// \note Any score kind after thisis considered a conversion that doesn't
Copy link
Contributor

Choose a reason for hiding this comment

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

this is*

default:
break;
}
if (isForCodeCompletion() && kind >= SK_SyncInAsync) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be done locally only for locations that involve code completion token in some way (calls with code completion in argument or member references with code completion token?

It's bad that we didn't use SK_NonDefaultLiteral unconditionally today because expressions like 1 + 2 + #^COMPLETE^# - would produce all possible permutations of non-default types like Int32, UInt16, Double etc. even for the first + which degrades performances significantly for filtering.

bool ExpectsNonVoid;
bool BaseIsStaticMetaType;

/// If the code completion expression occurrs as a single statement in a
Copy link
Contributor

Choose a reason for hiding this comment

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

occurs*

@ahoppen ahoppen force-pushed the ahoppen/dont-filter-based-on-conversions branch 3 times, most recently from 9dbf865 to 4cedc37 Compare March 1, 2023 13:07
@ahoppen ahoppen force-pushed the ahoppen/dont-filter-based-on-conversions branch 3 times, most recently from 593e52e to dbe9cec Compare March 14, 2023 17:49
…ving for code completion

Ignore conversion score increases during code completion to make sure we don't filter solutions that might start receiving the best score based on a choice of the code completion token.
@ahoppen ahoppen force-pushed the ahoppen/dont-filter-based-on-conversions branch from dbe9cec to 3481ac1 Compare March 14, 2023 21:19
@ahoppen
Copy link
Member Author

ahoppen commented Mar 14, 2023

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 14, 2023

@swift-ci Please SourceKit stress test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 15, 2023

This PR cases failures on its own and seems to require some of the changes in #63717. Merging the changes here as part of that PR.

@ahoppen ahoppen closed this Mar 15, 2023
@ahoppen ahoppen deleted the ahoppen/dont-filter-based-on-conversions branch March 15, 2023 14:39
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.

2 participants