Skip to content

for_in_of_invalid_element_type should differenciate type declaration #59712

@FMorschel

Description

@FMorschel

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

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-quick-fixIssues with analysis server (quick) fixesdevexp-serverIssues related to some aspect of the analysis servertype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions