Looks like that change is causing compiler tests to fail, so I am going to try 
to fix up FunctionCallEmitter now.

-Alex

On 2/26/20, 9:41 AM, "Alex Harui" <[email protected]> wrote:

    Hi Andrew,
    
    Harbs updated the file on royale-extras.  So you should now be able to 
build royale-typedefs (use "mvn clean" or "ant wipe" first to clear out the old 
version), then build royale-asjs and the compiler should no longer complain 
about the args.  Then updated FunctionCallEmitter if needed to get the right 
output.
    
    HTH,
    -Alex
    
    On 2/26/20, 1:47 AM, "Frost, Andrew" <[email protected]> wrote:
    
        Hi
        
        Thanks - so that looks like a good approach. I've just had a quick go 
at trying to hack this (the closure compiler jar file has a zip that contains 
this es3.js file..) but no joy so it looks like it needs to be built properly.
        
        If I was just to build that closure compiler (properly), and put the 
resulting JAR file into 
royale-asjs/js/lib/google/closure-compiler/compiler.jar, should that be 
sufficient? .. it doesn't actually seem like that jar file is being loaded at 
all when I compile, I've just renamed two folders:
        C:\Work\Royale\royale-asjs\js\lib\google
        so I no longer have "closure-compiler" or "closure-library", and I'm 
still getting it building (and failing):
        
        >c:\work\Royale\royale-asjs\js\bin\mxmlc TestArray.mxml
        Using Royale Compiler codebase: c:\Work\Royale\royale-asjs\js\bin\..\..
        Using Royale SDK: c:\Work\Royale\royale-asjs\js\bin\..\..
        MXMLJSC
        
-sdk-js-lib=c:\Work\Royale\royale-asjs\js\bin\..\..\frameworks\js\Royale\generated-sources
        TestArray.mxml
        C:\...\TestArray.mxml(20): col: 14 Error: Implicit coercion of a value 
of type Number to an unrelated type Function.
              a.sort(Array.DESCENDING);
        
        There's no such folder as the one being passed in to sdk-js-lib, don't 
know where that comes from but no 'Royale' folder under frameworks\js..
        
        So basically - once the closure compiler is updated, what happens next 
in order to get these definitions to be recognised within Royale?!
        
        
        thanks
        
           Andrew
        
        
        -----Original Message-----
        From: Alex Harui <[email protected]> 
        Sent: 26 February 2020 07:29
        To: [email protected]
        Subject: [EXTERNAL] Re: Array sort with numeric argument
        
        Hi Andrew,
        
        IIRC, there are a few places where we've already edited the JS 
definition, which is why the typedefs use custom versions of Google Closure's 
externs instead of externs directly from their repo.
        
        So I think it is just a matter of editing:
        
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fclicktime.symantec.com%2F3AafESw7XFxpnySNpTYup3L7Vc%3Fu%3Dhttps%253A%252F%252Fraw.githubusercontent.com%252Froyale-extras%252Fclosure-compiler%252Froyale%252Fexterns%252Fes3.js&amp;data=02%7C01%7Caharui%40adobe.com%7C910a5ed4648a489d2a8e08d7bae31f21%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637183356961762778&amp;sdata=MFCn2D37WmSFsci8fWdh5OMJGsDs6kLeCWeJBmeLH3E%3D&amp;reserved=0
        which I believe comes from
        
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fclicktime.symantec.com%2F3wUnMy1wgiKftPWEeyrXBx7Vc%3Fu%3Dhttps%253A%252F%252Fgithub.com%252Froyale-extras%252Fclosure-compiler%252Fblob%252Fmaster%252Fexterns%252Fes3.js&amp;data=02%7C01%7Caharui%40adobe.com%7C910a5ed4648a489d2a8e08d7bae31f21%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637183356961762778&amp;sdata=rwwseRP1%2Fm0nciXQ20zeemDbMOEljE%2BdXMCowR%2BBVF0%3D&amp;reserved=0
        
        If we change the parameter for Array.sort to the AS parameter list to 
(... args) instead of Function, then the final Array.as in royale-typedefs/js 
should allow anything there, and FunctionCallEmitter.java can pick up the extra 
cases and MethodBodySemanticChecker should not complain.
        
        I think Harbs owns that repo and can update that file.
        
        -Alex
        
        
        On 2/25/20, 10:58 PM, "Frost, Andrew" <[email protected]> wrote:
        
            Hi all
            
            Been a little while as I've been busy with AIR stuff, but we've 
also got a Royale project ongoing and we have an issue which I'm hoping can be 
fixed by a compiler update..
            
            The issue is really simple so I'm slightly surprised we're hitting 
this:
                  var a : Array = [ "one", "two", "three" ];
                  a.sort(Array.DESCENDING);
                  trace(a);
            
            This throws an ImplicitCoercionToUnrelatedTypeProblem
            and results in:
            Error: Implicit coercion of a value of type Number to an unrelated 
type Function.
                  a.sort(Array.DESCENDING);
            
            Presumably this is because the Array is a JavaScript class and it 
expects a compare function as the only option. AS3's definition of Array takes 
an optional number after the optional function (and is also very forgiving if 
you then add in extra unused parameters after those two..), so valid calls 
would be:
            sort(Number)
            sort(Function)
            sort(Function, Number)
            sort(Function, Number, anything else ..)
            i.e. the first argument must be a function or a number; if it' a 
function then the second argument must be a number.
            
            Note that there is code to actually handle the Array.sort() method 
and to check for a numeric first argument: if this is the case then it gets 
turned into Language.sort() - see FunctionCallEmitter.java.
            
            
            So my question really is, how do we add in the extra function 
overload definitions for this?
            
              *   is there a "proper" way that would ensure that the error 
isn't thrown by ensuring that the function definition is correct in the first 
place? Perhaps switching it to the AS3 definition of "function 
sort(...<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fclicktime.symantec.com%2F3UhYNbMDsk619zEbD94SWgU7Vc%3Fu%3Dhttps%253A%252F%252Fnam04.safelinks.protection.outlook.com%252F%253Furl%253Dhttps%25253A%25252F%25252Fhelp.adobe.com%25252Fen_US%25252FFlashPlatform%25252Freference%25252Factionscript%25252F3%25252Fstatements.html%252523..._%2528rest%2529_parameter%2526data%253D02%25257C01%25257Caharui%252540adobe.com%25257C8bc49bc1e3da4ce469f508d7ba893372%25257Cfa7b1b5a7b34438794aed2c178decee1%25257C0%25257C0%25257C637182970796966183%2526sdata%253D7t7BJmqI4yGxB9AO45fBcFqxzaQDgrlE%25252B8pXSaycXvU%25253D%2526reserved%253D0&amp;data=02%7C01%7Caharui%40adobe.com%7C910a5ed4648a489d2a8e08d7bae31f21%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637183356961772769&amp;sdata=SBi9T%2BUsFYPlsqJM4I21hIei9tOm7kSKDrMo%2BI2rXRk%3D&amp;reserved=0>
 
args):Array<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fclicktime.symantec.com%2F3qLbn7V3BiNf2ARiZqYA1G7Vc%3Fu%3Dhttps%253A%252F%252Fnam04.safelinks.protection.outlook.com%252F%253Furl%253Dhttps%25253A%25252F%25252Fhelp.adobe.com%25252Fen_US%25252FFlashPlatform%25252Freference%25252Factionscript%25252F3%25252FArray.html%2526data%253D02%25257C01%25257Caharui%252540adobe.com%25257C8bc49bc1e3da4ce469f508d7ba893372%25257Cfa7b1b5a7b34438794aed2c178decee1%25257C0%25257C0%25257C637182970796966183%2526sdata%253DrhCeq4hc2LK4QpBs2lY%25252F%25252FHPQo%25252FZ0AUM3gxXSgNMK9JI%25253D%2526reserved%253D0&amp;data=02%7C01%7Caharui%40adobe.com%7C910a5ed4648a489d2a8e08d7bae31f21%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7C637183356961772769&amp;sdata=chtcp1t0g4oGQlhfKhSNafRPuWo1YpJGIMs4MqrHtv8%3D&amp;reserved=0>"
 ?
              *   or, given we already have some hard-coded handling for this, 
would it be okay to add a special case into the 
MethodBodySemanticChecker.checkFunctionCall() method to handle this?
            
            I would prefer the former but am not sure whether we can just 
override a Java built-in definition, it's not quite the same as where we're 
adding missing properties such as the Array.DESCENDING stuff within the 
typedefs..
            If this can be done from there: can anyone remind me of the steps 
to take? I've had a go at adding overrides to the "missing.js" file and then 
compiled the typedefs using ant; no errors, and it had some "copying files" 
reported to the compiler and royale-asjs projects. But I still get the same 
error..
            
            
            Any thoughts appreciated!
            
            thanks
            
               Andrew
            
            
            
        
        
    
    

Reply via email to