"var self = this;” is added to every method that has inner/local
functions. Use of "this" in local functions is changed to use "self" in
order to get AS scoping in JS. I think we currently generate a self=this
even if the local functions don't need it. Someday the compiler will be
smarter about
The places that I checked look good.
Side question: Despite the fact that “this” is no longer used in the callLater
function, I noticed that the compiler is inserting "var self = this;” at the
start of the function.
I don’t think it causes any harm, but it does cause a Google compiler warning
I’m not going to claim I understand what you just wrote. ;-)
I’ll see if I can understand the output…
Thanks.
> On Jul 17, 2017, at 10:33 PM, Alex Harui wrote:
>
> Thinking about it more, I think a parameter of type Function never needs
> to be wrapped. It would get wrapped on any assignment
Thinking about it more, I think a parameter of type Function never needs
to be wrapped. It would get wrapped on any assignment in the function
body. I just pushed changes to reflect that.
-Alex
On 7/16/17, 11:41 PM, "Alex Harui" wrote:
>Seems reasonable to add a check to see if the function b
Seems reasonable to add a check to see if the function body is for a
static method.
-Alex
On 7/16/17, 11:25 PM, "Harbs" wrote:
>A directive could be a solution.
>
>But I think this is an issue with any static method. If a closure is used
>inside a static method, or a function declared inside a
A directive could be a solution.
But I think this is an issue with any static method. If a closure is used
inside a static method, or a function declared inside a static method, it
should not use Language.closure.
FWIW, the Google compile complains about “this” being used in a static method
as
I don't see any current way to suppress the Language.closure. Without
flow-analysis, I'm not sure the compiler can tell. It could guess that
the identifier is a parameter, but the parameter variable could be
assigned within the function body.
We could add a new directive like @flexjsisclosure or
I figured out the problem.
org.apache.flex.utils.callLater has the following code:
setTimeout(makeCalls, 0);
That compiles to:
setTimeout(org.apache.flex.utils.Language.closure(makeCalls, this,
'makeCalls'), 0);
When Language.closure is called, it messes up the scope of the calls variable
and