Skip to content

omit_local_variable_types false positive #58357

Open
@davidmorgan

Description

@davidmorgan

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.customer-google3devexp-linterIssues with the analyzer's support for the linter packagelinter-false-positiveIssues related to lint rules that report a problem when it isn't a problem.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions