Skip to content

Commit 7191549

Browse files
authored
Fix for @Option(transform:) with optional type (#619)
Due to the restructuring in #477, there was ambiguity between the unconstrained `@Option` initializer that uses a transform (but no initial value) and the one that is constrained to the property being optional. This marks the unconstrained version as disfavored, which allows overload resolution to select the optional version when appropriate. Also fixes this for `@Argument` and improves documentation consistency for `@Option`. Fixes #618.
1 parent 1c8215f commit 7191549

File tree

4 files changed

+200
-98
lines changed

4 files changed

+200
-98
lines changed

Sources/ArgumentParser/Documentation.docc/Extensions/Option.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
## Topics
44

5-
### Single Options
5+
### Single-Value Options
66

7-
- ``init(name:parsing:help:completion:)-7slrf``
87
- ``init(name:parsing:help:completion:)-4yske``
8+
- ``init(name:parsing:help:completion:)-7slrf``
9+
- ``init(wrappedValue:name:parsing:help:completion:)-7ilku``
910
- ``init(name:parsing:help:completion:transform:)-2wf44``
1011
- ``init(name:parsing:help:completion:transform:)-25g7b``
1112
- ``init(wrappedValue:name:parsing:help:completion:transform:)-2llve``
1213
- ``SingleValueParsingStrategy``
13-
- ``init(wrappedValue:name:parsing:help:completion:)-7ilku``
1414

1515
### Array Options
1616

Sources/ArgumentParser/Parsable Properties/Argument.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,7 @@ extension Argument {
414414
/// - transform: A closure that converts a string into this property's
415415
/// element type or throws an error.
416416
@preconcurrency
417+
@_disfavoredOverload
417418
public init(
418419
help: ArgumentHelp? = nil,
419420
completion: CompletionKind? = nil,

0 commit comments

Comments
 (0)