Skip to content

Work around invalid override error when args 2.7.0 is pulled in (Dart 3.3+ only issue) #448

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 1 commit into from
Mar 14, 2025

Conversation

greglittlefield-wf
Copy link
Contributor

@greglittlefield-wf greglittlefield-wf commented Mar 13, 2025

Motivation

The args package just released 2.7.0, which adds an optional param in ArgParser.flag.

Added option hideNegatedUsage to ArgParser.flag() allowing a flag to be negatable without showing it in the usage text.

This breaks dart_dev's override of this method, resulting in the following errors when attempting to analyze or run dart_dev code:

lib/src/tools/compound_tool.dart:262:8: Error: The method 'CompoundArgParser.addFlag' has fewer named arguments than those of overridden method 'ArgParser.addFlag'.
  void addFlag(String name,
       ^
/C:/Users/runneradmin/.pub-cache/hosted/pub.dev/args-2.7.0/lib/src/arg_parser.dart:134:8: Context: This is the overridden method ('addFlag').
  void addFlag(String name,
       ^
lib/src/tools/compound_tool.dart:262:8: Error: The method 'CompoundArgParser.addFlag' doesn't have the named parameter 'hideNegatedUsage' of overridden method 'ArgParser.addFlag'.
  void addFlag(String name,
       ^
/C:/Users/runneradmin/.pub-cache/hosted/pub.dev/args-2.7.0/lib/src/arg_parser.dart:[13](https://github.com/Workiva/dart_dev/actions/runs/13846410206/job/38745674756?pr=449#step:6:14)4:8: Context: This is the overridden method ('addFlag').
  void addFlag(String name,

This can be seen in the "Dart stable" CI runs here: #449

Note that this version of args has an SDK constraint of >=3.3.0, so this only affects Dart 3 consumers.

Solution

Add an arg of the same name to fix the analysis error.

Unless we want to constrain ourselves to args >= 2.7.0 (and as a result Dart >=3.3.0), we're unable to forward this argument, but since this new argument isn't critical, ignoring it for now seemed like a worthwhile tradeoff

Testing

CI passes in all Dart versions

@greglittlefield-wf greglittlefield-wf changed the title Work around invalid override when args 2.7.0 is pulled in Work around invalid override error when args 2.7.0 is pulled in (Dart 3.3+ only issue) Mar 13, 2025
@greglittlefield-wf greglittlefield-wf marked this pull request as ready for review March 13, 2025 23:21
@greglittlefield-wf greglittlefield-wf requested a review from a team as a code owner March 13, 2025 23:21
@matthewnitschke-wk
Copy link
Contributor

Thanks @greglittlefield-wf!

QA +1

  • CI does indeed pass

@matthewnitschke-wk
Copy link
Contributor

🚀 @Workiva/release-management-p 🚢

Copy link
Contributor

@rmconsole-wf rmconsole-wf left a comment

Choose a reason for hiding this comment

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

+1 from RM

@btr-rmconsole-3 btr-rmconsole-3 bot merged commit 3ed4f14 into master Mar 14, 2025
6 checks passed
@btr-rmconsole-3 btr-rmconsole-3 bot deleted the fix-args-2-7-0 branch March 14, 2025 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants