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

commit 06f6e5fa78b71a49cc4380764ec197acb4a8eac2
Author: greg-dove <greg.d...@gmail.com>
AuthorDate: Tue Oct 29 08:43:59 2019 +1300

    Fix for bindable support not working in File-private classes
---
 .../internal/codegen/js/jx/ClassEmitter.java       | 21 +++++++---
 .../codegen/js/jx/PackageHeaderEmitter.java        | 43 +--------------------
 .../codegen/js/royale/JSRoyaleEmitter.java         | 45 +++++++++++++++++++++-
 3 files changed, 61 insertions(+), 48 deletions(-)

diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ClassEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ClassEmitter.java
index c623780..f957ea2 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ClassEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/ClassEmitter.java
@@ -19,6 +19,7 @@
 
 package org.apache.royale.compiler.internal.codegen.js.jx;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.royale.compiler.asdoc.royale.ASDocComment;
@@ -35,10 +36,12 @@ import 
org.apache.royale.compiler.internal.codegen.js.royale.JSRoyaleEmitterToke
 import org.apache.royale.compiler.internal.codegen.js.utils.DocEmitterUtils;
 import org.apache.royale.compiler.internal.codegen.js.utils.EmitterUtils;
 import org.apache.royale.compiler.internal.projects.RoyaleJSProject;
+import org.apache.royale.compiler.internal.scopes.ASProjectScope;
 import org.apache.royale.compiler.internal.scopes.FunctionScope;
 import org.apache.royale.compiler.internal.tree.as.IdentifierNode;
 import org.apache.royale.compiler.tree.ASTNodeID;
 import org.apache.royale.compiler.tree.as.*;
+import org.apache.royale.compiler.units.ICompilationUnit;
 
 public class ClassEmitter extends JSSubEmitter implements
         ISubEmitter<IClassNode>
@@ -57,12 +60,22 @@ public class ClassEmitter extends JSSubEmitter implements
         RoyaleJSProject project = 
(RoyaleJSProject)getEmitter().getWalker().getProject();
         keepASDoc = project.config != null && project.config.getKeepASDoc();
         verbose = project.config != null && project.config.isVerbose();
-       
-        getModel().pushClass(node.getDefinition());
-
+       boolean isInternal = 
getModel().getInternalClasses().containsKey(node.getName());
+        IClassDefinition definition = node.getDefinition();
         // TODO (mschmalle) will remove this cast as more things get abstracted
         JSRoyaleEmitter fjs = (JSRoyaleEmitter) getEmitter();
         
+       if (isInternal) {
+           //process bindable support for possibly bindable internal 
(file-private) class:
+            ASProjectScope projectScope = project.getScope();
+            ICompilationUnit cu = projectScope
+                    .getCompilationUnitForDefinition(definition);
+            ArrayList<String> requiresList = project.getRequires(cu);
+            //the following needs to happen before getModel().pushClass for 
the internal class:
+            fjs.processBindableSupport(definition, requiresList);
+        }
+        getModel().pushClass(node.getDefinition());
+       
         ASDocComment asDoc = (ASDocComment) node.getASDocComment();
         if (asDoc != null && keepASDoc)
         {
@@ -80,8 +93,6 @@ public class ClassEmitter extends JSSubEmitter implements
 
         getModel().suppressExports = suppressExport;
 
-        IClassDefinition definition = node.getDefinition();
-
         IFunctionDefinition ctorDefinition = definition.getConstructor();
 
         // look for force-linking pattern in scope block node
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
index 154cd57..0fb9bed 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/jx/PackageHeaderEmitter.java
@@ -280,48 +280,7 @@ public class PackageHeaderEmitter extends JSSubEmitter 
implements
 
 
         if (type instanceof IClassDefinition) {
-            //check whether we should add the requires for the implicit 
Bindable EventDispatcher implementations
-            boolean needsBindableSupport = ((IClassDefinition) 
type).needsEventDispatcher(royaleProject);
-
-            if (needsBindableSupport) {
-                IClassDefinition bindableClassDef = (IClassDefinition) type;
-                ClassDefinition objectClassDefinition = 
(ClassDefinition)royaleProject.getBuiltinType(
-                        IASLanguageConstants.BuiltinType.OBJECT);
-
-                if 
(bindableClassDef.resolveBaseClass(royaleProject).equals(objectClassDefinition))
 {
-                    //keep the decision in the model for later
-                    getModel().registerImplicitBindableImplementation( 
bindableClassDef,
-                                                                       
ImplicitBindableImplementation.EXTENDS);
-                    // add the requiresList support for extending the 
dispatcher class
-                    if 
(!requiresList.contains(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME)))
 {
-                        
requiresList.add(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME));
-                    }
-                } else {
-                    //keep the decision in the model for later
-                    getModel().registerImplicitBindableImplementation( 
bindableClassDef,
-                                                                       
ImplicitBindableImplementation.IMPLEMENTS);
-                    //add the requiresList support for implementing 
IEventDispatcher
-                    if 
(!requiresList.contains(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_INTERFACE_QNAME)))
 {
-                        
requiresList.add(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_INTERFACE_QNAME));
-                    }
-                    if 
(!requiresList.contains(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME)))
 {
-                        
requiresList.add(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME));
-                    }
-                }
-            }
-
-            if (!needsBindableSupport) {
-                //we still need to check for static-only bindable 
requirements. If it was also instance-bindable,
-                //then the static-only requirements have already been met above
-                needsBindableSupport = ((IClassDefinition) 
type).needsStaticEventDispatcher(royaleProject);
-                //static-only bindable *only* requires the Dispatcher class, 
not the interface
-                if (needsBindableSupport
-                        && 
!requiresList.contains(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME)))
 {
-                    
requiresList.add(fjs.formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME));
-                }
-
-            }
-
+            ((JSRoyaleEmitter) 
getEmitter()).processBindableSupport((IClassDefinition) type, requiresList);
         }
 
         boolean emitsRequires = emitRequires(requiresList, writtenRequires, 
cname, royaleProject);
diff --git 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
index 66263b3..d73dfac 100644
--- 
a/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
+++ 
b/compiler-jx/src/main/java/org/apache/royale/compiler/internal/codegen/js/royale/JSRoyaleEmitter.java
@@ -72,6 +72,7 @@ import 
org.apache.royale.compiler.internal.codegen.js.jx.BinaryOperatorEmitter.D
 import org.apache.royale.compiler.internal.codegen.js.utils.EmitterUtils;
 import 
org.apache.royale.compiler.internal.codegen.mxml.royale.MXMLRoyaleEmitter;
 import org.apache.royale.compiler.internal.definitions.AccessorDefinition;
+import org.apache.royale.compiler.internal.definitions.ClassDefinition;
 import org.apache.royale.compiler.internal.definitions.FunctionDefinition;
 import org.apache.royale.compiler.internal.definitions.VariableDefinition;
 import org.apache.royale.compiler.internal.embedding.EmbedData;
@@ -81,7 +82,6 @@ import 
org.apache.royale.compiler.internal.projects.RoyaleJSProject;
 import org.apache.royale.compiler.internal.projects.RoyaleProject;
 import org.apache.royale.compiler.internal.scopes.FunctionScope;
 import org.apache.royale.compiler.internal.scopes.PackageScope;
-import org.apache.royale.compiler.internal.semantics.SemanticUtils;
 import org.apache.royale.compiler.internal.tree.as.*;
 import org.apache.royale.compiler.problems.EmbedUnableToReadSourceProblem;
 import 
org.apache.royale.compiler.problems.FilePrivateItemsWithMainVarWarningProblem;
@@ -1524,5 +1524,48 @@ public class JSRoyaleEmitter extends JSGoogEmitter 
implements IJSRoyaleEmitter
         ICompilerProject project = getWalker().getProject();
                return ((RoyaleJSProject)project).isGoogProvided(className);
        }
+       
+    public void processBindableSupport(IClassDefinition type,ArrayList<String> 
requiresList) {
+        ICompilerProject royaleProject = getWalker().getProject();
+        boolean needsBindableSupport = 
type.needsEventDispatcher(royaleProject);
+        if (needsBindableSupport) {
+            
+            IClassDefinition bindableClassDef = type;
+            ClassDefinition objectClassDefinition = 
(ClassDefinition)royaleProject.getBuiltinType(
+                    IASLanguageConstants.BuiltinType.OBJECT);
+            
+            if 
(bindableClassDef.resolveBaseClass(royaleProject).equals(objectClassDefinition))
 {
+                //keep the decision in the model for later
+                getModel().registerImplicitBindableImplementation( 
bindableClassDef,
+                        ImplicitBindableImplementation.EXTENDS);
+                // add the requiresList support for extending the dispatcher 
class
+                if 
(!requiresList.contains(formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME)))
 {
+                    
requiresList.add(formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME));
+                }
+            } else {
+                //keep the decision in the model for later
+                getModel().registerImplicitBindableImplementation( 
bindableClassDef,
+                        ImplicitBindableImplementation.IMPLEMENTS);
+                //add the requiresList support for implementing 
IEventDispatcher
+                if 
(!requiresList.contains(formatQualifiedName(BindableEmitter.DISPATCHER_INTERFACE_QNAME)))
 {
+                    
requiresList.add(formatQualifiedName(BindableEmitter.DISPATCHER_INTERFACE_QNAME));
+                }
+                if 
(!requiresList.contains(formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME)))
 {
+                    
requiresList.add(formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME));
+                }
+            }
+        }
+        
+        if (!needsBindableSupport) {
+            //we still need to check for static-only bindable requirements. If 
it was also instance-bindable,
+            //then the static-only requirements have already been met above
+            needsBindableSupport = ((IClassDefinition) 
type).needsStaticEventDispatcher(royaleProject);
+            //static-only bindable *only* requires the Dispatcher class, not 
the interface
+            if (needsBindableSupport
+                    && 
!requiresList.contains(formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME)))
 {
+                
requiresList.add(formatQualifiedName(BindableEmitter.DISPATCHER_CLASS_QNAME));
+            }
+        }
+    }
 
 }

Reply via email to