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

omit_local_variable_types false positive #58357

Open
davidmorgan opened this issue Mar 23, 2021 · 3 comments
Open

omit_local_variable_types false positive #58357

davidmorgan opened this issue Mar 23, 2021 · 3 comments
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-google3 linter-false-positive P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@davidmorgan
Copy link
Contributor

It looks like the lint considers Foo<dynamic> and Foo<Object> to be the same, so it doesn't allow a left hand side type to 'cast' between the two:

class A<T> {
  T _value;
  A(this._value);
 
  T get value => _value;
}

class Foo {
  String foo;
 
  Foo(this.foo);
}

A<Object> b() {
  return A<Foo>(Foo('hello world'));
}

void main() async {
  // This gives #omit_local_variable_types
  // final A a = b();
  // This gives The getter 'foo' isn't defined for the class 'Object'.
  final a = b();
  final s = a.value.foo;
  print(s);
}
@pq pq added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) customer-google3 linter-false-positive labels Mar 23, 2021
@srawlins srawlins added the P2 A bug or feature request we're likely to work on label Oct 26, 2022
@srawlins
Copy link
Member

I believe this is a duplicate of #58201, which has lots of discussion.

@davidmorgan
Copy link
Contributor Author

@srawlins I don't think it's a duplicate:

@pq pq reopened this Nov 14, 2022
@srawlins
Copy link
Member

Good catch.

@devoncarew devoncarew added analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Nov 19, 2024
@devoncarew devoncarew transferred this issue from dart-lang/linter Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-linter Issues with the analyzer's support for the linter package area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. customer-google3 linter-false-positive P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants