-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CodeCompletion] Avoid re-typechecking pre-checked expressions #31774
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
[CodeCompletion] Avoid re-typechecking pre-checked expressions #31774
Conversation
rdar://problem/60982638
in expression context analysis. They are simply not necessary. rdar://problem/60982638
@swift-ci Please smoke test |
@xedin Could you review |
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.
LGTM!
If SanitizeExpr is |
One we integrate code completion into solutions with fixes scheme we can finally deprecate |
@slavapestov Unfortunately we cannot remove |
|
||
auto baseTy = (*baseTyOpt)->getWithoutSpecifierType(); | ||
Type baseTy = baseExpr->getType(); | ||
if (!baseTy || baseTy->is<ErrorType>()) { |
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.
Why is it safe to re-check when it's ErrorType?
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.
It should be safe for any expression as long as SanitizeExpr
works correctly.
This change is a kind of optimization which avoids unnecessary re-typechecking.
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.
So this change does not affect the correctness of this patch?
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.
Right. The first patch fixes the crash. The second patch doesn't affect the result of it.
Implicit call expressions for "KeyPath expression as functions" weren't sanitized in
SanitizeExpr
. That leavesAutoClosureExpr
in the AST before re-typechecking, and caused crashes.Handle them in
SanitizeExpr
. (the first commit)But we don't need to re-typecheck them in the first place. (the second commit)
rdar://problem/60982638