This is an automated email from the ASF dual-hosted git repository.
joshtynjala pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-compiler.git
The following commit(s) were added to refs/heads/develop by this push:
new 52b0dd9 AccessorEmitter: always use nocollapse for static accessors
(closes #200)
52b0dd9 is described below
commit 52b0dd9dc64945f5ace8d1bb8ebf1db05c04a158
Author: Josh Tynjala <[email protected]>
AuthorDate: Wed Dec 15 14:03:04 2021 -0800
AccessorEmitter: always use nocollapse for static accessors (closes #200)
Closure compiler seems to correctly rename accessors when they are on the
prototype, but it only renames references when accessors are static, so
nocollapse is needed as a workaround. We might be able to remove this in the
future, if Closure ever fixes the issue. For now, since this code is not
dynamic (we allow dynamic code to break when we don't prevent renaming), this
nocollapse workaround is necessary to allow setting prevent-rename compiler
options to false without breaking non-d [...]
---
.../royale/compiler/internal/codegen/js/jx/AccessorEmitter.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
index bc8aa0c..4c45cf7 100644
---
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
+++
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/AccessorEmitter.java
@@ -551,8 +551,13 @@ public class AccessorEmitter extends JSSubEmitter
implements
writeNewline();
writeNewline();
writeNewline("/**");
- if (p.preventRename)
- writeNewline(" * @nocollapse");
+ // like instance accessors, we should have if
(p.preventRename)
+ // here, but while Closure compiler seems to properly
handle
+ // renaming of instance accessors, it fails when we try
the same
+ // trick with static accessors, unless there's a
nocollapse.
+ // when we allow renaming, we don't want to break anything
that
+ // isn't dynamic access, so we always need nocollapse here.
+ writeNewline(" * @nocollapse");
if (p.resolvedExport && !p.suppressExport)
writeNewline(" * @export");
if (p.type != null)