Skip to content

Strong mode and dart:core's "Function" #27457

Closed
@matanlurey

Description

@matanlurey

The Function interface is used by several packages, such as package:test to be able to declare the input/output is a Function, no matter how many arguments/signature. That's nice. But...

I'm getting a "Unsound implicit cast from Function to () -> dynamic".

I'm not sure how to solve this nicely. You can see a reproduction case on Dartpad, or below:

void main() {
  run(expectAsync((String t) {}));
}

Function expectAsync(Function callback) => callback;

/*=E*/ run/*<E>*/(/*=E*/ action(String t)) => action('Hello');

I realize this might not be "strong mode" safe. If so, what is the Future of Function?

/cc @vsmenon @leafpetersen @nex3

Metadata

Metadata

Assignees

No one assigned

    Labels

    closed-duplicateClosed in favor of an existing report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions