Skip to content

[ownership] Convert ValueOwnershipKind to have an Invalid state instead of using optional. #34659

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

gottesmm
Copy link
Contributor

At Andy's request. If it creates too much noise in covered switches, we may go
back to the original.

…ad of using optional.

At Andy's request. If it creates too much noise in covered switches, we may go
back to the original.
@gottesmm gottesmm requested a review from atrick November 10, 2020 18:36
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Please get rid of the special-casing for Invalid. Otherwise this looks great.

Optional is appropriate when a particular API may fail. But here "Invalid" is actually an expected state, and normal state for constraints. It just means "any" or "unknown" ownership which happens to be invalid when applied to values because we have strict ownership rules for values.

// If either lhs or rhs are invalid, return invalid.
if (lhsVal == ValueOwnershipKind::Invalid ||
rhsVal == ValueOwnershipKind::Invalid)
return ValueOwnershipKind::Invalid;
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't be special-casing invalid here.

@gottesmm
Copy link
Contributor Author

Going to fix Andys comments in a follow up.

@gottesmm gottesmm merged commit 1ff9147 into swiftlang:main Nov 10, 2020
@gottesmm gottesmm deleted the pr-5755ffcaf1433708dd6843521b63d70405f75d65 branch November 10, 2020 21:27
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