Skip to content

Generic function can't be passed as an argument #55770

Open
@seha-bot

Description

@seha-bot

This code compiles fine, but the analyser gives an error:

The argument type 'List<T> Function<T>(T)' can't be assigned to the parameter type 'List<Z0> Function<F>(F)'. 

Code:

List<T> toList<T>(T x) => [x];

R calc<R>(R Function<F>(F) f) {
  return f(0);
}

void main() {
  final res = calc(toList);
  print(res);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-dart-modelFor issues related to conformance to the language spec in the parser, compilers or the CLI analyzer.dart-model-analyzer-specIssues with the analyzer's implementation of the language spectype-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