Skip to content

[CS] Remove assertion that callee locator has an anchor #59997

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

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Jul 11, 2022

When computing type relations of code completion items with respect to the context they are used in, we add a ConstraintKind::Conversion constraint with an empty constraint locator.
https://github.com/apple/swift/blob/99ee194482d6f5a26c8e95ae5dca9e47db07ad78/lib/Sema/TypeCheckConstraints.cpp#L1022
This currently crashes in hasPreconcurrencyCallee.

To fix this crash, just return false in these cases.

This fixes a crash found by the SourceKit stress tester that was introduced by #59958.

@ahoppen ahoppen requested review from xedin and DougGregor July 11, 2022 09:53
@ahoppen
Copy link
Member Author

ahoppen commented Jul 11, 2022

@swift-ci Please smoke test

@ahoppen ahoppen force-pushed the pr/empty-locator-has-no-preconcurrency branch from 5e6ad05 to 4201829 Compare July 14, 2022 13:41
When computing type relations of code completion items with respect to the context they are used in, we add a `ConstraintKind::Conversion` constraint with an empty constraint locator. This currently crashes in `hasPreconcurrencyCallee`, but actually having a null anchor doesn’t produce any issues.
@ahoppen ahoppen force-pushed the pr/empty-locator-has-no-preconcurrency branch from 4201829 to ae53e8a Compare July 14, 2022 13:45
@ahoppen
Copy link
Member Author

ahoppen commented Jul 14, 2022

@swift-ci Please smoke test

@ahoppen ahoppen changed the title [CS] Don’t crash if locator passed to hasPreconcurrencyCallee has no anchor [CS] Remove assertion that callee locator has an anchor Jul 14, 2022
@ahoppen ahoppen merged commit 393626f into swiftlang:main Jul 14, 2022
@ahoppen ahoppen deleted the pr/empty-locator-has-no-preconcurrency branch July 14, 2022 20:02
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