Remove ExpressibleByArgument
conformance from Optional
#173
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This drops the
ExpressibleByArgument
conformance forOptional
. This conformance doesn't quite make sense, and allowed property declarations like this:The default value meant that
count
would never benil
, and therefore shouldn't be optional.Detailed Design
This change adds initializers specifically for when an
Option
's orArgument
's value is optional, without adefault
parameter as well as deprecated versions that include adefault
parameter to guide clients to the correct declaration syntax.Documentation Plan
The new initializers are documented; related initializers have been updated. There is no change required in the guides.
Test Plan
Existing tests exercise the functionality and verify the largely source-compatible nature of the change.
Source Impact
While this is technically source-breaking, it should have minimal impact in regular usage. All the declaration sites for arguments and options with optional values are still supported, with deprecation warnings for declarations that combine a default value and an optional type. If a property is declared as optional but does not have a default value, there won't even be a deprecation notice.
Code that uses
Optional
's conformance toExpressibleByArgument
, however, will break without warning. Users can work around this by adding anOptional
-specific code path, or by other means.Checklist