joshtynjala edited a comment on issue #207:
URL: 
https://github.com/apache/royale-compiler/issues/207#issuecomment-1015864334


   As I was writing that, I wondered if it would be clear enough using 
`Object`, or if I should use more specific classes. I guess I should have been 
more specific after all.
   
   Let me fix that. This should be allowed:
   
   ```as3
   var fun:Function.<(ev:MouseEvent):void> = function(ev:Event):void {};
   ```
   
   I don't have the types backwards.
   
   Consider the following, which is allowed in AS3 code that exists today:
   
   ```
   function myListener(event:Event):void {}
   myListener(new MouseEvent());
   ```
   
   This is why `myListener` should be allowed to be assigned to `var 
fun:Function.<(ev:MouseEvent):void>`. Because the type is `Event`, it can 
accept any subclass, including `MouseEvent`..
   
   Function types in Haxe and TypeScript both work how I describe. Here's a 
TypeScript example:
   
   ```ts
   let myListener1: (event: MouseEvent)=>void = function(event: Event) {} // no 
problem!
   let myListener2: (event: Event)=>void = function(event: MouseEvent) {} // 
error!
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to