Skip to content

[Typechecker] Fix a few regressions with @autoclosure #28677

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
Dec 17, 2019
Merged

[Typechecker] Fix a few regressions with @autoclosure #28677

merged 3 commits into from
Dec 17, 2019

Conversation

theblixguy
Copy link
Collaborator

@theblixguy theblixguy commented Dec 10, 2019

Since Swift 5.1, we have a few regressions around the use of @autoclosure.

  1. We are crashing if the @autoclosure type is not a function type, but just a variadic type. For example:
func foo(_ closure: @autoclosure String...) {} // crash
  1. We're not correctly enforcing the use of @autoclosure in parameter position. For example, the following does not get diagnosed, even though it should:
let foo: Array<@autoclosure String> = [] // no error
  1. If we have () -> String... as the type and we pass it a value, then we crash in CSApply after diagnosing the error. I have filed a separate bug for it.

Resolves SR-11934, SR-11938
Resolves: rdar://problem/57824033

@theblixguy theblixguy requested a review from xedin December 10, 2019 18:25
@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test

@theblixguy
Copy link
Collaborator Author

@swift-ci please smoke test macOS

@theblixguy theblixguy changed the title [Typechecker] Fix a regression with variadic types not being diagnosed with @autoclosure [Typechecker] Introduce a new request to check the structure of @autoclosure Dec 11, 2019
@theblixguy theblixguy requested a review from CodaFi December 11, 2019 17:56
@xedin
Copy link
Contributor

xedin commented Dec 16, 2019

@theblixguy Could we please limit this to your original fix? I can get that into master and 5.2. Requestifying can happen after.

@theblixguy
Copy link
Collaborator Author

Sure! I’ll split the request into a separate PR.

@xedin
Copy link
Contributor

xedin commented Dec 16, 2019

Thank you!

@theblixguy
Copy link
Collaborator Author

@xedin Done. I have kept the core logic as is, but removed all the requestification bits. It passes all tests in attr_autoclosure.swift.

@theblixguy theblixguy changed the title [Typechecker] Introduce a new request to check the structure of @autoclosure [Typechecker] Fix a few regressions with @autoclosure Dec 16, 2019
@xedin
Copy link
Contributor

xedin commented Dec 16, 2019

@swift-ci please test

@xedin
Copy link
Contributor

xedin commented Dec 16, 2019

@swift-ci please test source compatibility

@swift-ci

This comment has been minimized.

@swift-ci

This comment has been minimized.

@theblixguy theblixguy removed the request for review from CodaFi December 16, 2019 23:38
@theblixguy
Copy link
Collaborator Author

Okay, tests have pretty much passed (just waiting for Release source compat). I'll create a new PR for 5.2 branch

@xedin
Copy link
Contributor

xedin commented Dec 17, 2019

Sounds good! Thank you, @theblixguy!

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.

4 participants