-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
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:
- specification text Restrict behavior of callable classes - specification text #32153
- front end CFE in strong mode does not implement proper subtyping rules for callable objects #32064
- VM Restrict behavior of callable classes - VM implementation #32154
- dart2js Restrict behavior of callable classes - dart2js implementation #32155
- analyzer Restrict behavior of callable classes - analyzer implementation #32156
- DDC Restrict behavior of callable classes - DDC implementation #32157
- Verify tests are passing
- Documentation