Skip to content

Type inference for arguments does not handle closurization of methods correctly #4515

@sgjesse

Description

@sgjesse

The following code:

class A {
  a(x) => x + 1;
}

f(p) => p("A");

main() {
  A a = new A();
  a.a(1);
  print(f(a.a));
}

Fails on the VM with NoSuchMethodException : method not found: '+'.

On dart2js (r10701) the generated JavaScript code does not fail but instead prints "A1".

It is the same issue if an explicit closure is used. like this:

class A {
  a(x) => x + 1;
}

f(p) => p("A");

main() {
  A a = new A();
  a.a(1);
  print(f((x) => (a.a(x))));
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1A high priority bug; for example, a single project is unusable or has many test failuresweb-dart2js

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions