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

aharui 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 10ecfc4  fix another custom namespace scenario.  Fixes 
apache/royale-asjs#419.
10ecfc4 is described below

commit 10ecfc4788f9f6d82adf4e2c8bcdd81116b47df1
Author: Alex Harui <[email protected]>
AuthorDate: Wed Jun 12 10:45:56 2019 -0700

    fix another custom namespace scenario.  Fixes apache/royale-asjs#419.
---
 .../internal/codegen/js/goog/JSGoogEmitter.java      | 10 +++++++++-
 .../codegen/js/royale/TestRoyaleExpressions.java     | 20 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/goog/JSGoogEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/goog/JSGoogEmitter.java
index 1b7aacf..0d495f7 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/goog/JSGoogEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/goog/JSGoogEmitter.java
@@ -954,7 +954,15 @@ public class JSGoogEmitter extends JSEmitter implements 
IJSGoogEmitter
         }
         else
         {
-            getWalker().walk(node);
+            if (definition instanceof IFunctionDefinition &&
+                       node.getNodeID() == 
ASTNodeID.NamespaceAccessExpressionID)
+            {
+               // can't do normal walk.  Need to generate closure
+               // so walk just the right operand
+               getWalker().walk(node.getChild(1));
+            }
+            else
+               getWalker().walk(node);
         }
     }
 
diff --git 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
index 55de5e5..48ec475 100644
--- 
a/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
+++ 
b/compiler-jx/src/test/java/org/apache/royale/compiler/internal/codegen/js/royale/TestRoyaleExpressions.java
@@ -1144,6 +1144,26 @@ public class TestRoyaleExpressions extends 
TestGoogExpressions
     }
     
     @Test
+    public void testCustomNamespaceMethodAsParameter()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "import custom.custom_namespace; use namespace 
custom_namespace;public class B {custom_namespace function b() { function 
c(f:Function):void {}; c(b); }}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @export\n 
*/\nB.prototype.http_$$ns_apache_org$2017$custom$namespace__b = function() {\n  
var self = this;\n  function c(f) {\n  };\n  
c(org.apache.royale.utils.Language.closure(this.http_$$ns_apache_org$2017$custom$namespace__b,
 this, 'http://ns.apache.org/2017/custom/namespace::b'));\n}");
+    }
+    
+    @Test
+    public void testCustomNamespaceMethodAsParameterWithoutUse()
+    {
+        IFunctionNode node = (IFunctionNode) getNode(
+                "import custom.custom_namespace;public class B 
{custom_namespace function b() { function c(f:Function):void {}; 
c(custom_namespace::b); }}",
+                IFunctionNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitFunction(node);
+        assertOut("/**\n * @export\n 
*/\nB.prototype.http_$$ns_apache_org$2017$custom$namespace__b = function() {\n  
var self = this;\n  function c(f) {\n  };\n  
c(org.apache.royale.utils.Language.closure(this.http_$$ns_apache_org$2017$custom$namespace__b,
 this, 'http://ns.apache.org/2017/custom/namespace::b'));\n}");
+    }
+    
+    @Test
     public void testCustomNamespaceMethodAsVariable()
     {
         IFunctionNode node = (IFunctionNode) getNode(

Reply via email to