You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ah...@apache.org on 2018/11/16 06:51:08 UTC

[royale-compiler] 01/02: SWFOverrides work if the actual types used can be subclasses of, or implement the interfaces in the original type. However, for DisplayObject.graphics, the Graphics class is final so we can't play with a subclass. So we are forced to cheat and have the compiler switch out references to graphics with royalegraphics which is added to UIComponent

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

commit 1063bf810a0928ba7d5d0bebf0fa6e8f51e683c3
Author: Alex Harui <ah...@apache.org>
AuthorDate: Thu Nov 15 14:54:44 2018 -0800

    SWFOverrides work if the actual types used can be subclasses of, or implement the interfaces in the original type.  However, for DisplayObject.graphics, the Graphics class is final so we can't play with a subclass.  So we are forced to cheat and have the compiler switch out references to graphics with royalegraphics which is added to UIComponent
---
 .../royale/compiler/internal/tree/as/IdentifierNode.java       | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/IdentifierNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/IdentifierNode.java
index ccad9d6..a218644 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/IdentifierNode.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/IdentifierNode.java
@@ -392,6 +392,8 @@ public class IdentifierNode extends ExpressionNodeBase implements IIdentifierNod
             if (qualifier == null)
             {
                 result = asScope.findProperty(project, name, getDependencyType(), isTypeRef());
+                if (result != null && name.equals("graphics") && ((ITypeDefinition)(result.getParent())).isInstanceOf("mx.core.UIComponent", project))
+                	result = asScope.findProperty(project, "royalegraphics", getDependencyType(), isTypeRef());
                 // ASVariableTests_localVarSameNameAsPrivateMethod
                 if (isLegacyCodegen(project) && result != null && getParent().getNodeID() == ASTNodeID.FunctionCallID && result instanceof VariableDefinition)
                 {
@@ -878,7 +880,7 @@ public class IdentifierNode extends ExpressionNodeBase implements IIdentifierNod
         IDefinition result = null;
 
         // Determine baseType, the type of 'a' (the left-hand-side of the member access operator).
-        IDefinition baseType = null;
+        ITypeDefinition baseType = null;
         ExpressionNodeBase baseExpr = getBaseExpression();
         if (baseExpr != null)
         {
@@ -920,6 +922,12 @@ public class IdentifierNode extends ExpressionNodeBase implements IIdentifierNod
                 }
                 if (qualifier != null)
                     result = asScope.getQualifiedPropertyFromDef(project, baseType, name, qualifier, isSuper);
+                else if (name.equals("graphics") && baseType.isInstanceOf("mx.core.UIComponent", project))
+                {
+                	result = asScope.getPropertyFromDef(project, baseType, "royalegraphics", isSuper);
+                    if (result == null)
+                        result = asScope.getPropertyFromDef(project, baseType, name, isSuper);
+                }
                 else
                     result = asScope.getPropertyFromDef(project, baseType, name, isSuper);
             }