support universal function types #526
Description
Initial implementation of #301 may not cover this.
- ensure these have a runtime representation (likely done as part of Reify type in "generic" methods #301)
- implement subtyping rules
- prevent these types from being treated as callable functions (e.g.
(f.runtimeType as dynamic)(int)
where f is a generic function). Discussed at the end.
These can't be written down yet, but they can come up in inference, for example:
/*=T*/ f/*<T>*/(/*=T*/x) => x;
main() {
var y = f;
y = /*<S>*/(y) => y; // legal
}
Note the generic function expression is #527
I'm not aware of this blocking anything, but for consistentcy with Analyzer we should support it.
Regarding "prevent these types from being treated as callable functions": we may need to split out into its own bug, as it likely requires changing how generic classes look. Generic class types & function typedefs are callable, which was okay because they weren't accessible as first-class values. But universal function types can be gotten from .runtimeType
, and will likely have a literal form as well: MyGenericFnType
. It's not a huge problem if that value is "dynamically callable", since the Type interface does not say anything about supporting call, but it seems suboptimal.