Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics for methods #7099

Closed
DartBot opened this issue Dec 3, 2012 · 3 comments
Closed

Generics for methods #7099

DartBot opened this issue Dec 3, 2012 · 3 comments
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug

Comments

@DartBot
Copy link

DartBot commented Dec 3, 2012

This issue was originally filed by [email protected]


Not able to find much info in the spec for this. Coming from C# I can do things with generics such as...

class A
{
  var _list = new List<B>();

  T add<T>(){
    if(T is B){
      var newT = new T();
      _list.add(newT);
      return newT;
    }
  }
}

abstract class B
{

}

class C extends B
{

}

main(){
  var a = new A();
  var c = a.add<C>();
}

However this doesn't seem supported in Dart; am I missing something?

@anders-sandholm
Copy link
Contributor

Removed Type-Defect label.
Added Type-Enhancement, Area-Language, Triaged labels.

@kevmoo
Copy link
Member

kevmoo commented Dec 5, 2012

An oldie but a goodie

Star this guy: https://code.google.com/p/dart/issues/detail?id=254

@gbracha
Copy link
Contributor

gbracha commented Jan 22, 2013

Added Duplicate label.
Marked as being merged into #254.

@DartBot DartBot added Type-Enhancement area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report labels Jan 22, 2013
@kevmoo kevmoo added type-enhancement A request for a change that isn't a bug and removed type-enhancement labels Mar 1, 2016
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-language Dart language related items (some items might be better tracked at github.com/dart-lang/language). closed-duplicate Closed in favor of an existing report type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

4 participants