[ 
https://issues.apache.org/jira/browse/FLEX-33903?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13822532#comment-13822532
 ] 

Alex Harui commented on FLEX-33903:
-----------------------------------

The behavior of "as" is different from the coercion function because the 
coercion function throws an exception if the type is not compatible.

But I was pondering how many folks will need to rely on this at runtime in JS.  
If you truly followed the FlexJS workflow and tested your app in Flash, then in 
most cases you know that the type is compatible, and you are mainly doing the 
"cast" to make the compiler happy and/or get code-completion.  So one option is 
to simply skip the call altogether.  That way we won't spend time calling "as". 
 Or maybe output different code based on some flag.

Also, don't forget that you have to handle top-level functions like Date(xxx) 
differently than DataGrid(xxx).

> Type coercion missing, perhaps
> ------------------------------
>
>                 Key: FLEX-33903
>                 URL: https://issues.apache.org/jira/browse/FLEX-33903
>             Project: Apache Flex
>          Issue Type: Bug
>          Components: FalconJX, FlexJS
>         Environment: Mac OS X
>            Reporter: Peter Ent
>            Assignee: Erik de Bruin
>
> I have AS code like this (from org.apache.flex.html.staticControls.DataGrid):
> public function set dataProvider(value:Object):void
> {
>    IDataGridModel(model).dataProvider = value;
> }
> Compiling into JavaScript the result looks like:
> org.apache.flex.html.staticControls.DataGrid.prototype.set_dataProvider = 
> function(value) {
>   IDataGridModel(this.get_model()).set_dataProvider(value);
> };
> The causes "IDataGridModel not found" runtime error. I believe IDataGridModel 
> should be fully qualified (the goog.require is in the file) but perhaps that 
> even would not produce the correct coercion (not sure, really).



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to