Skip to content
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.

support universal function types #526

Closed
@jmesserly

Description

@jmesserly

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions