Skip to content

Remove a non-useful type check on generic type variable #3457

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 3 commits into from
Dec 27, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/src/dartdoc_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,8 @@ class DartdocOptionArgSynth<T> extends DartdocOption<T>
String help = '',
OptionKind optionIs = OptionKind.other,
this.negatable = false})
: assert(T is! Iterable),
: assert(const <Never>[] is! T,
'$T should not be bound to a type which allows iterables'),
Copy link
Member

@lrhn lrhn Jun 29, 2023

Choose a reason for hiding this comment

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

This would indeed allow T to be Set, which is iterable.

To check whether T is/is not a subtype of Iterable, you need to put T on the LHS of the is check, e.g., <T>[] is! List<Iterable>.

Copy link
Member

Choose a reason for hiding this comment

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

But... the comment says to not allow any type which allows an iterable. That suggests not allowingObject either.
In practice any non-final type may allow an iterable, so I wouldn't try to do anything for that.

super(name, null, help, optionIs, mustExist, null, resourceProvider);

@override
Expand Down