Skip to content

Support declaration of generic type for methods #254

@alxhub

Description

@alxhub

Dart should support generic methods/functions, similar to Java:

class Foo<E> {
  E _item;

  /* ... */

  <T> T transform(T fn(E)) {
    return fn(_item);
  }
}

Currently this is supported only by omitting the type information. Additionally, some core Dart code includes the <T> annotation within comments: /<T>/. In order for proper tool/IDE support, Dart should support explicitly declaring generic types for a method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-languageDart language related items (some items might be better tracked at github.com/dart-lang/language).type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions