Closed
Description
Start with a typedef: typedef EventHandler<T>(Object sender, T args);
Then a method with EventHandler<T> as a param:
class SomeClass<T> {
void add(EventHandler<T> handler){
...
}
}
Then usage:
var someClass = new SomeClass<int>();
Calling add w/ a valid handler makes the editor happy.
Calling add w/ a number someClass.add(5)
shows an error: 'int is not assignable to EventHandler<int>' as expected.
Calling add w/ a random object `someClass.add(new Object()) shows no error in the editor, although it blows up wonderfully at runtime.
Attachment:
[Screen Shot 2012-05-30 at 10.19.11 AM.png](https://storage.googleapis.com/google-code-attachments/dart/issue-3316/comment-0/Screen Shot 2012-05-30 at 10.19.11 AM.png) (22.21 KB)