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
commit 522010b9408b35e49f30d4f06d30160c9b735789 Author: Josh Tynjala <[email protected]> AuthorDate: Fri Jun 5 16:30:38 2026 -0700 IdentifierEmitter: Fixed missing require for package-level functions or variables in some situations. The qname wasn't being formatted, so it wasn't considered used. Now, format it without emitting the formatted name. --- RELEASE_NOTES.md | 1 + .../internal/codegen/js/jx/IdentifierEmitter.java | 24 ++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index af8f0eb55..e9d7a3813 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -83,6 +83,7 @@ Apache Royale Compiler 1.0.0 - compiler: Support resource bundles with `JS` target, similar to `JSRoyale`. - compiler: Fixed rare race condition where certain cached values are detected as non-null but become null before the method returns. - compiler: Fixed parsing of namespace uri and manifest mappings to allow multiple manifest paths per URI. +- compiler: Fixed missing require for package-level functions or variables in some situations. - debugger: Added missing isolate ID to SWF load and unload events. - debugger: Fixed debugger targeting the current JDK version instead of the intended minimum JDK version. - debugger: Fixed localized messages appearing as unprocessed tokens. diff --git a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java index c504d7bd6..0927b3453 100644 --- a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java +++ b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/IdentifierEmitter.java @@ -206,12 +206,17 @@ public class IdentifierEmitter extends JSSubEmitter implements // sure it is ok to always use the short name in an MAE String qname = nodeDef.getQualifiedName(); boolean isPackageOrFileMember = false; + boolean isPackageMember = false; if (nodeDef instanceof IVariableDefinition) { IVariableDefinition variable = (IVariableDefinition) nodeDef; VariableClassification classification = variable.getVariableClassification(); - if (classification == VariableClassification.PACKAGE_MEMBER || - classification == VariableClassification.FILE_MEMBER) + if (classification == VariableClassification.PACKAGE_MEMBER) + { + isPackageOrFileMember = true; + isPackageMember = true; + } + else if (classification == VariableClassification.FILE_MEMBER) { isPackageOrFileMember = true; } @@ -235,8 +240,12 @@ public class IdentifierEmitter extends JSSubEmitter implements { IFunctionDefinition func = (IFunctionDefinition) nodeDef; FunctionClassification classification = func.getFunctionClassification(); - if (classification == FunctionClassification.PACKAGE_MEMBER || - classification == FunctionClassification.FILE_MEMBER) + if (classification == FunctionClassification.PACKAGE_MEMBER) + { + isPackageOrFileMember = true; + isPackageMember = true; + } + else if (classification == FunctionClassification.FILE_MEMBER) { isPackageOrFileMember = true; } @@ -248,6 +257,13 @@ public class IdentifierEmitter extends JSSubEmitter implements //if the package or file member isn't on the left side of a //member access expression, it shouldn't be fully qualified needsFormattedName = parentMemberAccessNode.getLeftOperandNode() == node; + if (!needsFormattedName && isPackageMember && project.isGoogProvided(qname)) + { + // it needs to be required, though, so we'll format it + // without emitting the formatted name because that will + // add it to the used names + fjs.formatQualifiedName(qname); + } } if (parentNodeId == ASTNodeID.MemberAccessExpressionID) {
