You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by jo...@apache.org on 2025/10/27 22:56:06 UTC

(royale-compiler) 03/03: MXMLScopeBuilder/MXMLFileScope: use a PackageScope as the containing scope for a type created with fx:Component

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 c2484a6b983321341e7cc3f176ca631c63fab7a8
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Oct 27 15:54:42 2025 -0700

    MXMLScopeBuilder/MXMLFileScope: use a PackageScope as the containing scope for a type created with fx:Component
    
    The class inside fx:Component should be able to access internal methods in the same package. This improves compatibility with the Flex SDK compiler.
---
 .../compiler/internal/parsing/mxml/MXMLScopeBuilder.java     |  2 +-
 .../royale/compiler/internal/scopes/MXMLFileScope.java       | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/mxml/MXMLScopeBuilder.java b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/mxml/MXMLScopeBuilder.java
index f441c556c..f02d8caa8 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/mxml/MXMLScopeBuilder.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/parsing/mxml/MXMLScopeBuilder.java
@@ -651,7 +651,7 @@ public class MXMLScopeBuilder
             
             // Add a class definition for the component class to the file scope.
             ClassDefinition fxComponentClassDefinition =
-                fileScope.addFXComponent(qname, componentTag.getAbsoluteStart(), className, baseClassQName);
+                fileScope.addFXComponent(qname, componentTag.getAbsoluteStart(), className, baseClassQName, packageScope);
             fxComponentClassDefinition.setNameLocation(nameStart, nameEnd);
             
             if (className == null)
diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/MXMLFileScope.java b/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/MXMLFileScope.java
index 4ffb06506..61902e102 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/MXMLFileScope.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/scopes/MXMLFileScope.java
@@ -203,6 +203,16 @@ public class MXMLFileScope extends ASFileScope implements IXMLNameResolver
                                           int componentTagStart,
                                           String componentClassName,
                                           String componentBaseClassQName)
+    {
+        return addFXComponent(mainClassQName, componentTagStart, componentClassName, componentBaseClassQName, this);
+    }
+
+
+    public ClassDefinition addFXComponent(String mainClassQName,
+                                          int componentTagStart,
+                                          String componentClassName,
+                                          String componentBaseClassQName,
+                                          ASScope parentScope)
     {
         // Use the class name specified by the <code>className</code> attribute,
         // or generate a unique class name for the new component class,
@@ -227,7 +237,7 @@ public class MXMLFileScope extends ASFileScope implements IXMLNameResolver
         addDefinition(fxComponentClassDefinition);
 
         // Create a class scope for the component class.
-        TypeScope classScope = new TypeScope(this, fxComponentClassDefinition);
+        TypeScope classScope = new TypeScope(parentScope, fxComponentClassDefinition);
         classScope.setContainingDefinition(fxComponentClassDefinition);
         fxComponentClassDefinition.setContainedScope(classScope);
         fxComponentClassDefinition.setupThisAndSuper();