This is an automated email from the ASF dual-hosted git repository.

gregdove 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 461a66b  Fix for bad transpile with fully qualified imported function 
and "js=dynamic-access-unknown-members=true"
461a66b is described below

commit 461a66b8a52d1f79f2332d047f646ad3549930c4
Author: greg-dove <[email protected]>
AuthorDate: Thu Jul 9 17:07:02 2020 +1200

    Fix for bad transpile with fully qualified imported function and 
"js=dynamic-access-unknown-members=true"
---
 .../codegen/js/jx/FunctionCallEmitter.java         | 24 +++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
index f4e711b..f15b440 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/FunctionCallEmitter.java
@@ -42,6 +42,7 @@ import org.apache.royale.compiler.internal.tree.as.*;
 import org.apache.royale.compiler.problems.TooFewFunctionParametersProblem;
 import org.apache.royale.compiler.problems.TooManyFunctionParametersProblem;
 import org.apache.royale.compiler.projects.ICompilerProject;
+import org.apache.royale.compiler.scopes.IFileScope;
 import org.apache.royale.compiler.tree.ASTNodeID;
 import org.apache.royale.compiler.tree.as.*;
 import org.apache.royale.compiler.utils.NativeUtils;
@@ -666,7 +667,28 @@ public class FunctionCallEmitter extends JSSubEmitter 
implements ISubEmitter<IFu
                     write(ASEmitterTokens.PAREN_CLOSE);
                     return;
                 }
-               getWalker().walk(node.getNameNode());
+
+               if (def != null
+                        && node.getNameNode() instanceof 
IMemberAccessExpressionNode
+                        && def.getContainingScope() instanceof IFileScope) {
+                    //this code branch covers a scenario where fully qualified 
imported functions had their package elements
+                    //swapped to dynamic-access when 
js-dynamic-access-unknown-members=true, which should not happen.
+                    //This was observed when the imported function call was 
being used 'fully qualified' inside
+                    //a locally defined function with the same name (where 
fully qualified access was of course needed)
+                    //example:
+                    // import org.apache.royale.test.asserts.assertTrue; 
//import original function
+                    //
+                    //  public function assertTrue(message:String, 
condition:Boolean):void{
+                    //    
org.apache.royale.test.asserts.assertTrue(condition,message); // without this 
branch in the compiler it was being expressed as org["apache"]["royale"]...etc
+                    //  }
+
+                   startMapping(node.getNameNode());
+                   write(def.getQualifiedName());
+                   endMapping(node.getNameNode());
+                } else {
+                    getWalker().walk(node.getNameNode());
+                }
+
 
                 getEmitter().emitArguments(node.getArgumentsNode());
     

Reply via email to