Skip to content

IUO: Put the pieces in place to handle coercions and casts to IUO types. #13722

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
Jan 4, 2018
Merged

IUO: Put the pieces in place to handle coercions and casts to IUO types. #13722

merged 1 commit into from
Jan 4, 2018

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented Jan 4, 2018

For casts like 'x as T!' or 'x as! T!', generate a disjunction that
attempts to bind both the optional and non-optional T, preferring the
optional branch of the disjunction.

Note that this should effectively be NFC at the moment because we're
still generating the IUO type for T! rather than a plain optional, so
we first attempt the IUO type (as opposed to an Optional) which
goes through existing logic that handles the IUOs as part of the type
system.

The new rewriting logic will actually do something once we switch over
to generating Optional when T! is uttered.

For casts like 'x as T!' or 'x as! T!', generate a disjunction that
attempts to bind both the optional and non-optional T, preferring the
optional branch of the disjunction.

Note that this should effectively be NFC at the moment because we're
still generating the IUO type for T! rather than a plain optional, so
we first attempt the IUO type (as opposed to an Optional<T>) which
goes through existing logic that handles the IUOs as part of the type
system.

The new rewriting logic will actually do something once we switch over
to generating Optional<T> when T! is uttered.
@rudkx
Copy link
Contributor Author

rudkx commented Jan 4, 2018

@swift-ci Please smoke test

@rudkx rudkx merged commit 76941d4 into swiftlang:master Jan 4, 2018
@rudkx rudkx deleted the coercions-and-casts-to-IUO branch January 4, 2018 16:12
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.

1 participant