-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[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
Conversation
Since we migrated all of code completion to solver-based, this flag is no longer needed.
c97ed7a
to
52e5d1a
Compare
@swift-ci Please smoke test |
@swift-ci Please SourceKit stress test |
There was a problem hiding this 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.
52e5d1a
to
66a0b78
Compare
@swift-ci Please smoke test |
@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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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());
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this 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
.
ClosuresInResultBuilderDontParticipateInInference
flag from the constraint systemTypeCheckASTNodeAtLocRequest
cs.isForCodeCompletion()
instead of checking for presence ofCompletionCallback