Skip to content

[ConstraintSystem] Don't bind result type of an empty closure too early #30838

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 1 commit into from
Apr 7, 2020

Conversation

xedin
Copy link
Contributor

@xedin xedin commented Apr 6, 2020

Instead of setting empty closure ({}) result type to be Void
while generating constraints, let's allocate a new type variable
instead and let it be bound to Void once the body is opened.

This way we can support an interaction with function builders which
would return a type different from Void even when applied to empty closure.

Resolves: rdar://problem/61347993

@xedin xedin requested a review from DougGregor April 6, 2020 20:08
Copy link
Member

@DougGregor DougGregor left a comment

Choose a reason for hiding this comment

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

Nice solution to this!

@xedin
Copy link
Contributor Author

xedin commented Apr 6, 2020

@swift-ci please smoke test

@xedin
Copy link
Contributor Author

xedin commented Apr 6, 2020

Hm, this is interesting somehow test/SILOptimizer/return.swift is failing now in cases where are no closures involved...

Instead of setting empty closure (`{}`) result type to be `Void`
while generating constraints, let's allocate a new type variable
instead and let it be bound to `Void` once the body is opened.

This way we can support an interaction with function builders which
would return a type different from `Void` even when applied to empty closure.

Resolves: rdar://problem/61347993
@xedin
Copy link
Contributor Author

xedin commented Apr 6, 2020

@swift-ci please smoke test

@xedin xedin merged commit bd44fb3 into swiftlang:master Apr 7, 2020
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