Skip to content

for_in_of_invalid_element_type should differenciate type declaration #59712

Open
@FMorschel

Description

Repro

a.dart

class A {}
List<A> foo() => [A()];

main.dart

import 'a.dart';

class A {}

void main() {
  for (A a in foo()) {
  }
}

Shows:

The type 'List<A>' used in the 'for' loop must implement 'Iterable' with a type argument that can be assigned to 'A'.

Similar to #56505.

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestanalyzer-quick-fixanalyzer-serverarea-analyzerUse area-analyzer for Dart analyzer issues, including the analysis server and code completion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions