Skip to content

Implicitly tear off call from receiver whose type is a type variable #54351

@eernstg

Description

@eernstg

Thanks to @johnniwinther for noticing this. Consider the following program:

class A {
  void call() {}
}

Function f<X extends A>(X x) => x;

void main() {
  print(f(A()));
}

This program is rejected by the analyzer as well as the common front end (DartPad based on SDK 3.3.0-213.0.dev). However, the interface of a receiver of type X is the interface of the bound A, which implies that the interface of x does include a method named call, which means that we should be able to tear it off implicitly when the context type is Function or a function type.

The missing support for call is concerned with implicit tear-offs only, the implicit insertion of call that enables an invocation is working in the analyzer as well as the CFE.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).type-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