Skip to content

Conversation

natecook1000
Copy link
Member

@natecook1000 natecook1000 commented Nov 16, 2022

This change is to make sure that the non-optional generic parameter type is chosen for @Argument and @Option properties that provide a default value. Previously, an optional type might be chosen depending on how the help parameter was spelled, due to strange overload resolution. In particular, using the .init caused selection of the deprecated optional overload:

// Unexpected: // Infers `Value` as `Optional<AbsolutePath>` @Argument(help: .init("The path")) var path = AbsolutePath("/") // Expected: // Infers `Value` as `AbsolutePath` @Argument(help: "The path") var path = AbsolutePath("/")

This addresses the issue by marking the deprecated overloads as disfavored. rdar://102383455

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary
This change is to make sure that the non-optional generic parameter type is chosen for @argument and @option properties that provide a default value. Previously, an optional type might be chosen depending on how the `help` parameter was spelled, due to strange overload resolution. In particular, using the `.init` caused selection of the deprecated optional overload: // Unexpected: // Infers `Value` as `Optional<AbsolutePath>` @argument(help: .init("The path")) var path = AbsolutePath("/") // Expected: // Infers `Value` as `AbsolutePath` @argument(help: "The path") var path = AbsolutePath("/") This addresses the issue by marking the deprecated overloads as disfavored. rdar://102383455
@natecook1000
Copy link
Member Author

@swift-ci Please test

@natecook1000 natecook1000 merged commit f94e4b9 into apple:main Nov 16, 2022
@natecook1000 natecook1000 deleted the disfavor_deprecated_inits branch November 16, 2022 15:30
wrappedValue: Value,
help: ArgumentHelp? = nil,
completion: CompletionKind? = nil
) where Value: ExpressibleByArgument {
Copy link
Contributor

Choose a reason for hiding this comment

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

Just curious: does this change affect overload resolution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants