Skip to content
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

always_specify_types falsely positives alias types of classes with type generics. #2671

Open
Michael35699 opened this issue May 25, 2021 · 4 comments
Labels
customer-flutter false-positive P3 A lower priority bug or feature request set-flutter-dev Affects a rule used in the Flutter repo type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@Michael35699
Copy link

Describe the issue
A clear and concise description of what the issue is.

typedef ZTable = HashMap<String, String>;

void main() {
  ZTable table = ZTable(); // Specify type annotations.
}

I believe this is unexpected behavior, since the types are already declared.

To Reproduce

Given example above

Expected behavior

There would be no lint error.

Additional context

N/A

@pq pq added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) false-positive labels Jun 16, 2021
@yjbanov
Copy link

yjbanov commented Jul 15, 2021

This also happens in other contexts:

typedef Json = Map<String, dynamic>;

extension JsonMethod on Json {
//                      ^^^^ here
  Json dict(String propertyName) {
//^^^^ here
    return this[propertyName] as Json;
//                               ^^^^ here
  }
}

@asashour
Copy link
Contributor

asashour commented Jul 29, 2021

I am not able to reproduce on master, but I am able to reproduce with Dart SDK version: 2.14.0-321.0.dev

Could it be that the linter is somehow different from the one in the SDK, that discrepancy is also shown in #2597

With master, adding the far below at the end of always_specify_types.dart test case gives successful result, although putting a wrong LINT gives an error

EXPERIMENT_NOT_ENABLED: This requires the 'nonfunction-type-aliases' language feature to be enabled.

Test case:

typedef ZTable = HashMap<String, String>;

void m() {
  ZTable table = ZTable(); // OK
}

typedef Json = Map<String, dynamic>;

extension JsonMethod on Json {
  Json dict(String propertyName) {
    return this[propertyName] as Json;
  }
}

@bwilkerson
Copy link
Member

Which master? On the master branch of the SDK that feature is marked as being enabled by default, so you shouldn't see the EXPERIMENT_NOT_ENABLED diagnostic.

@asashour
Copy link
Contributor

I meant linter master, at the moment I didn't go into the SDK and see how to use a modified linter, this would be the next step.

At the moment, I hope someone points to a reproducible issue in linter master, so it can be modified and tested there.

@bwilkerson bwilkerson added set-flutter-dev Affects a rule used in the Flutter repo P3 A lower priority bug or feature request labels Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-flutter false-positive P3 A lower priority bug or feature request set-flutter-dev Affects a rule used in the Flutter repo type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants