Skip to content

[Sema] Some more cleanup now that we migrated all of code completion to solver-based #68363

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 5 commits into from
Sep 16, 2023

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 6, 2023

  • Delete the ClosuresInResultBuilderDontParticipateInInference flag from the constraint system
  • Don’t set actor isolation in TypeCheckASTNodeAtLocRequest
  • Check cs.isForCodeCompletion() instead of checking for presence of CompletionCallback

Since we migrated all of code completion to solver-based, this flag is no longer needed.
@ahoppen ahoppen force-pushed the ahoppen/more-cc-cleanup branch from c97ed7a to 52e5d1a Compare September 7, 2023 20:15
@ahoppen ahoppen marked this pull request as ready for review September 7, 2023 20:15
@ahoppen
Copy link
Member Author

ahoppen commented Sep 7, 2023

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 7, 2023

@swift-ci Please SourceKit stress test

Copy link
Contributor

@hamishknight hamishknight left a comment

Choose a reason for hiding this comment

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

Awesome!

…equest`

Since we migrated all of code completion to solver-based, this is no longer needed.
…nce of `CompletionCallback`

This shouldn’t really change anything but is just a little cleaner.
…rticipatesInInference`

It looks like we no longer need this check.
@ahoppen ahoppen force-pushed the ahoppen/more-cc-cleanup branch from 52e5d1a to 66a0b78 Compare September 8, 2023 15:29
@ahoppen
Copy link
Member Author

ahoppen commented Sep 8, 2023

@swift-ci Please smoke test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 8, 2023

@swift-ci Please SourceKit stress test

@@ -7311,24 +7311,13 @@ bool ConstraintSystem::participatesInInference(ClosureExpr *closure) const {
if (getAppliedResultBuilderTransform(closure))
return true;

if (closure->hasSingleExpressionBody())
return true;

if (Options.contains(ConstraintSystemFlags::LeaveClosureBodyUnchecked))
return false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, I think if we're keeping the LeaveClosureBodyUnchecked flag, then we'll probably want to restore the hasSingleExpressionBody check since I assume LeaveClosureBodyUnchecked is only meant to apply to multi-statement closures?

Copy link
Member Author

Choose a reason for hiding this comment

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

You might be right. But things are looking good right now even without the check. Let’s see what the stress tester has to say

Copy link
Member Author

Choose a reason for hiding this comment

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

Appears to be fine even with closure->hasSingleExpressionBody removed.

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 think hasSingleExpressionBody is necessary and you can remove isInResultBuilderContext method too since this was the last use of it. The only question I have is why do we have this setup in a way that getAppliedResultBuilderTransform doesn't respect LeaveClosureBodyUnchecked...

I think this method should look as follows:

return !(Options.contains(ConstraintSystemFlags::LeaveClosureBodyUnchecked) || closure->hasEmptyBody());

Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't getAppliedResultBuilderTransform needed because we still generate a result builder body that needs type-checking even if the parsed body is empty?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good point, I think we should add an method to get a body for a closure and use the result to check whether it's empty or not, seems like that would minimize the risk of making mistakes like that...

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.

I have a few ideas how to improve performance of closure type-checking which would enable removal of LeaveClosureBodyUnchecked.

@ahoppen ahoppen merged commit e2eaad5 into swiftlang:main Sep 16, 2023
@ahoppen ahoppen deleted the ahoppen/more-cc-cleanup branch September 16, 2023 15:01
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