Skip to content

Restrict behavior of callable classes #32152

@stereotype441

Description

@stereotype441

In Dart 2.0, we would like to change to the behavior of callable classes (classes containing a .call method) so that they are no longer considered a subtype of the function type of their .call method.

Instead, to support almost all existing code, the call method will be implicitly torn off where statically detectable (but dynamic invocation of a class with a call method will still be allowed).

Rationale: This feature has never paid its way as far as complexity it adds to the type system and the implementations. It has been (and probably still is) the source of various bugs. It also complicates our calling conventions in generated code - we cannot assume a function is actually a function. In general, we believe fixing google3 code will be faster than properly implementing and will probably result in better generated code.

Test cases for this change were added to the tests/language_2 subdirectory in f0a6330.

This is an overall tracking bug. Individual implementations are tracked in their own sub-bugs:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-metaCross-cutting, high-level issues (for tracking many other implementation issues, ...).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions