Skip to content

[TypeChecker] Prevent pattern resolution from triggering type-checking for unresolved references #39399

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 3 commits into from
Sep 23, 2021

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Sep 22, 2021

Workaround for Clang enum typaliases called isInvalid() and getInterfaceType()
on discovered declarations. That doesn't play well with result builders because
declarations/patterns used in the body of a result builder don't get a type until
a solution is applied. Calling isInvalid() or getInterfaceType on declarations
located in the body of a result builder trigger a separate type-check for the
declaration that interferes with builder transformation and leads to crashes.

@xedin xedin requested review from slavapestov and hborla September 22, 2021 19:36
@xedin
Copy link
Contributor Author

xedin commented Sep 22, 2021

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Sep 22, 2021

@swift-ci please test source compatibility

if (cs.isDebugMode()) {
auto &log = llvm::errs();

log << "--- Applying result builder to function ---\n";
Copy link
Member

Choose a reason for hiding this comment

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

Nice, this will be super helpful in debug-constraints output 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, it's going to be a good indicator what is being processed piecemeal, otherwise it's sometimes unclear where the sub-targets are coming from...

@xedin
Copy link
Contributor Author

xedin commented Sep 22, 2021

@swift-ci please smoke test Windows platform

…g for unresolved references

Workaround for Clang enum typaliases called `isInvalid()` and `getInterfaceType()`
on discovered declarations. That doesn't play well with result builders because
declarations/patterns used in the body of a result builder don't get a type until
a solution is applied. Calling `isInvalid()` or `getInterfaceType` on declarations
located in the body of a result builder trigger a separate type-check for the
declaration that interferes with builder transformation and leads to crashes.
@xedin xedin force-pushed the result-builder-switch branch from 690cb80 to 3710967 Compare September 22, 2021 23:45
@xedin
Copy link
Contributor Author

xedin commented Sep 22, 2021

I have changed to check for hasInterfaceType() and left a comment that explains why this is necessary what what happens if we simply remove the check.

@xedin
Copy link
Contributor Author

xedin commented Sep 22, 2021

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Sep 23, 2021

@swift-ci please smoke test Windows platform

…rEnumElement`

Since re-declaration error is going to be emitted anyway it doesn't
matter which declaration would get returned.
@xedin
Copy link
Contributor Author

xedin commented Sep 23, 2021

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Sep 23, 2021

As suggested by @slavapestov removed both isInvalid check and related assertion.

@xedin xedin merged commit d0ac02d into swiftlang:main Sep 23, 2021
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