IMO, the -warn-public-vars is more about the "renaming" mentioned in that link 
than the "collapse".

If you have:

Package {
Class Josh {
  Public var name:String;
}
Var foo:Josh = new Josh();
foo.name = 'josh';

I don't think @nocollapse will prevent renaming the 'name' property to 
something random like 'jt':

Var foo = new Josh();
foo.jt = 'josh';

AIUI, @nocollapse is used for things that are not obviously mutable.  If you 
look in the globals in the browser debugger for any js-debug version of a 
Royale app, you can see the structure:

   org.apache.royale.core

It was created by code similar to:

window.org = {};
window.org.apache = {};
window.org.apache.royale = {};
window.org.apache.royale.core = {};

Then some class gets added:

window.org.apache.royale.core.UIBase = function ()...

And some static might get added to that:

window.org.apache.royale.core.UIBase.FOO = "BAR";

Closure will collapse org.apache.royale.core to just something like "bb" in the 
js-release output.  And that means that code that sets UIBase.FOO will break 
because there won't be an org.apache.royale.core structure.  AIUI, nocollapse 
would prevent collapsing that structure, but won't prevent UIBase and FOO from 
being renamed.  And the renaming mainly causes problems when deserializing data 
structures coming from a server or other external source.

Of course, I could be wrong...
-Alex

On 9/16/19, 9:07 AM, "Josh Tynjala" <joshtynj...@bowlerhat.dev> wrote:

    I was looking through the Closure compiler annotations, and I noticed
    @nocollapse:
    
    Denotes a property that should not be collapsed by the compiler into a
    > variable. The primary use for @nocollapse is to allow exporting of mutable
    > properties.
    >
    
    
https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fgoogle%2Fclosure-compiler%2Fwiki%2FAnnotating-JavaScript-for-the-Closure-Compiler%23nocollapse&amp;data=02%7C01%7Caharui%40adobe.com%7C0444699041f3402d06c908d73abff16c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637042468374325733&amp;sdata=P%2FqQl7pq69YhAYtZQdKEHKnbgPuGDuD%2BikOca3aTOGY%3D&amp;reserved=0
    
    Isn't this collapsing behavior the reason why we needed to add
    -warn-public-vars?
    
    --
    Josh Tynjala
    Bowler Hat LLC 
<https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbowlerhat.dev&amp;data=02%7C01%7Caharui%40adobe.com%7C0444699041f3402d06c908d73abff16c%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C1%7C637042468374335722&amp;sdata=%2BwzLkQRXkpBeaII1wYWrT1z4fb%2FqKt3Qn2O7q1K1j3w%3D&amp;reserved=0>
    

Reply via email to