Skip to content

[NFC] Fold The Tri-State In Optional<ProtocolConformanceRef> #27949

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 5 commits into from
Oct 30, 2019

Conversation

CodaFi
Copy link
Contributor

@CodaFi CodaFi commented Oct 30, 2019

ProtocolConformanceRef already has an invalid state. Use this instead of None to signal something has gone wrong or a witness is missing. As this makes ProtocolConformanceRef behave like an Optional, give it an operator bool and a default constructor and clean up all the call sites.

The result has been clang-format'ed with some minor revisions to keep noise down. I apologize in advance for the size of this patch, but there should be no behavior changes so the diff should be read as a 1-1 mapping between APIs.

ProtocolConformanceRef already has an invalid state.  Drop all of the
uses of Optional<ProtocolConformanceRef> and just use
ProtocolConformanceRef::forInvalid() to represent it.  Mechanically
translate all of the callers and callsites to use this new
representation.
Use ProtocolConformanceRef::forInvalid() in implementations only as a semantic signal.  In one place, use the default constructor to drop the final use of Optional<ProtocolConformanceRef>.
ProtocolConformanceRef::isConcrete checks the invalid bit for us.
@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 30, 2019

@swift-ci please test

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 30, 2019

@swift-ci please test source compatibility

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - e7006a9

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.

This all looks reasonable to me, although wow is it a big change

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 30, 2019

Infrastructure outage

@swift-ci please test

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 30, 2019

@swift-ci please test source compatibility

@CodaFi
Copy link
Contributor Author

CodaFi commented Oct 30, 2019

⛵️

@CodaFi CodaFi merged commit 5f3b1da into swiftlang:master Oct 30, 2019
@CodaFi CodaFi deleted the protoplasmic-supine-jellies branch October 30, 2019 14:47
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