Skip to content

[CodeCompletion] Migrate expression completions to solver-based #41633

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
merged 1 commit into from
Mar 21, 2022

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Mar 2, 2022

Migrate StmtOrExpr completions to solver-based.

@ahoppen ahoppen force-pushed the pr/solver-based-global-completions branch from bc8a25a to f698b2c Compare March 4, 2022 09:39
@ahoppen ahoppen changed the title [WIP][CodeCompletion] Migrate global/expression completions to solver-based [CodeCompletion] Migrate global/expression completions to solver-based Mar 4, 2022
@ahoppen ahoppen requested review from xedin and rintaro March 4, 2022 09:44
@ahoppen ahoppen marked this pull request as ready for review March 4, 2022 09:45
@ahoppen ahoppen changed the title [CodeCompletion] Migrate global/expression completions to solver-based [CodeCompletion] Migrate expression completions to solver-based Mar 4, 2022
SolutionApplicationTarget target(closure, closure,
ContextualTypePurpose::CTP_CallArgument,
contextualType, /*isDiscarded=*/false);
setSolutionApplicationTarget(closure, target);
Copy link
Member Author

Choose a reason for hiding this comment

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

@xedin I’m pretty sure this part is not correct. As we discussed, I’m using SolutionApplicationTarget to convey the contextual type of the ClosureExpr. I’m not entirely sure what you’d expect for the decl context, contextual type purpose and isDiscarded. AFAICT, we don’t really know the contextual type purpose and whether it’s discarded inside resolveClosure.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest you add a new ContextualTypePurpose - CTP_Closure, declaration context of this target should be the one associated with constraint system and isDiscarded is false in here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks. I changed it.

Copy link
Contributor

@xedin xedin left a comment

Choose a reason for hiding this comment

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

Looked only at the last commit.

SolutionApplicationTarget target(closure, closure,
ContextualTypePurpose::CTP_CallArgument,
contextualType, /*isDiscarded=*/false);
setSolutionApplicationTarget(closure, target);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd suggest you add a new ContextualTypePurpose - CTP_Closure, declaration context of this target should be the one associated with constraint system and isDiscarded is false in here.

/// "resolved" concrete type.
/// If no type has been computed for this node or if \c node is null, returns
/// the null type.
Type getResolvedTypeIfAvailable(ASTNode node) const;
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see any uses of this but I'd say that if ASTNode doesn't have a type it's either not associated with the solution which is an issue on the caller side, or it didn't get recorded during constraint generation, which makes it a bug in the solver.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, looks like the need for that method has gone away at some point during my development. I just removed it.

@ahoppen
Copy link
Member Author

ahoppen commented Mar 19, 2022

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 19, 2022

@swift-ci Please SourceKit stress test

@ahoppen
Copy link
Member Author

ahoppen commented Mar 21, 2022

Stress tester run: https://ci.swift.org/job/swift-PR-macos-with-sourcekit-stress-tester/44/

This needs some XFails due to SR-16012 and a performance problem I’m addressing in separately in #41917.

@ahoppen ahoppen force-pushed the pr/solver-based-global-completions branch from 53a677f to e2a62f1 Compare March 21, 2022 12:00
@ahoppen
Copy link
Member Author

ahoppen commented Mar 21, 2022

@swift-ci Please smoke test

@ahoppen ahoppen merged commit 458ce70 into swiftlang:main Mar 21, 2022
@ahoppen ahoppen deleted the pr/solver-based-global-completions branch March 21, 2022 19:02
ahoppen added a commit to ahoppen/swift-source-compat-suite that referenced this pull request Mar 23, 2022
- SR-14694: A few timeout issues were resolved by swiftlang/swift#41917 and others were introduced by swiftlang/swift#41633.

- SR-16012: A couple more cases were caused by migrating expression completions to solver-based swiftlang/swift#41633
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