Stop removing underscores from CodingKey names in InputKey #548
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.
When a property wrapper is applied to a property, the property's storage is given a name with a prefixed underscore. That is, for a property named
x
, the actual storage is named_x
.That prefixed storage is what is visible through reflection, so when building an
ArgumentSet
from a command type's mirror, we need to remove the leading underscore. This is done when creating anInputKey
for each property.However,
InputKeys
are also created fromCodingKeys
during decoding of a command. TheseCodingKeys
do not have the leading underscore that is added by the property wrapper, so any underscores that appear are actually from the declaration of the property with an underscored name. Removing leading underscores fromCodingKey
names results in a mismatch when trying to find the decoded value. For example, for a simple command declared like this:Running:
repro --arg foo
fails to parse with the error:This change simplifies the
InputKey
type to use an array path instead of an indirect enum and removes the leading underscore dropping when creating anInputKey
from aCodingKey
.rdar://104928743
Checklist