-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Don’t compute isolated parameter captures during code completion #73659
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
@swift-ci Please smoke test |
if (checkIsolatedCapture) { | ||
if (auto param = closure->getCaptureInfo().getIsolatedParamCapture()) | ||
return ActorIsolation::forActorInstanceCapture(param) | ||
.withPreconcurrency(preconcurrency); | ||
} else { | ||
// If we don't have capture information during code completion, assume | ||
// that the closure captures the `isolated` parameter from the parent | ||
// context. | ||
return parentIsolation; | ||
} |
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 guess an alternative solution would be to call computeCaptures
(or setCaptureInfo
) for completion to just populate an empty set of captures. Can't say I really love either solution, but I think I would mildly prefer populating empty captures since it's less invasive.
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.
@slavapestov Do you have a preference on whether we should call computeCaptures
in completion even though we know that it will compute incomplete captures or have a parameter like this? Hamish and I don’t have super strong opinions either way.
func test(foo: isolated Foo) { | ||
foo.#^COMPLETE^# | ||
} |
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.
This test case doesn't have any closures, does it trigger the crash without the fix?
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.
Oh, yes. Indeed. I was trying other things in there and then forgot to reset it. Thanks for noticing.
…e completion Computing capture information requires a type checked AST, which we don’t have during code completion. To fix an assertion failure, don’t look for a captured `isolated` parameter while computing a closure’s actor isolation during code completion. rdar://126923558
a7256b1
to
22f0daf
Compare
@swift-ci Please smoke test |
Computing capture information requires a type checked AST, which we don’t have during code completion. To fix an assertion failure, don’t look for a captured
isolated
parameter while computing a closure’s actor isolation during code completion.rdar://126923558