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


The following commit(s) were added to refs/heads/develop by this push:
     new 8efe085  SemanticUtils: resolveXML() and resolveXMLType() resolve 
private/protected members in XML/XMLList so that they aren't coerced
8efe085 is described below

commit 8efe0852161cce2fb325f415574b2e6380eb2a12
Author: Josh Tynjala <joshtynj...@apache.org>
AuthorDate: Wed Feb 20 14:12:13 2019 -0800

    SemanticUtils: resolveXML() and resolveXMLType() resolve private/protected 
members in XML/XMLList so that they aren't coerced
---
 .../compiler/internal/semantics/SemanticUtils.java | 49 +++++++++++++---------
 1 file changed, 30 insertions(+), 19 deletions(-)

diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java
index 9972ec5..c17d4d0 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/SemanticUtils.java
@@ -967,7 +967,7 @@ public class SemanticUtils
             IFunctionDefinition functionDef = (IFunctionDefinition) def;
             return functionDef.resolveReturnType(project);
         }
-        return null;
+        return def.resolveType(project);
     }
 
     /**
@@ -989,30 +989,41 @@ public class SemanticUtils
                 IMemberAccessExpressionNode memberAccess = 
(IMemberAccessExpressionNode) nameNode;
                 nameNode = memberAccess.getRightOperandNode();
             }
-            if (nameNode instanceof IdentifierNode)
+            if (nameNode instanceof IIdentifierNode)
             {
-                IdentifierNode rightIdentifier = (IdentifierNode) nameNode;
-                if (rightIdentifier.isMemberRef())
+                IdentifierNode identifierNode = (IdentifierNode) nameNode;
+                IDefinition resolvedDef = identifierNode.resolve(project);
+                if (resolvedDef != null && isXMLish(resolvedDef.getParent(), 
project))
                 {
-                    ITypeDefinition baseType = null;
-                    ExpressionNodeBase baseExpr = 
rightIdentifier.getBaseExpression();
-                    if (baseExpr != null)
-                    {
-                        baseType = baseExpr.resolveType(project);
-                    }
-                    if(isXMLish(baseType, project))
+                    if (resolvedDef instanceof IFunctionDefinition
+                            && !(resolvedDef instanceof IAccessorDefinition))
                     {
-                        ASScope asScope = rightIdentifier.getASScope();
-                        IDefinition propertyDef = 
asScope.getPropertyFromDef(project, baseType, rightIdentifier.getName(), false);
-                        if (propertyDef instanceof IFunctionDefinition &&
-                            !(propertyDef instanceof IAccessorDefinition))
-                        {
-                            IFunctionDefinition functionDef = 
(IFunctionDefinition) propertyDef;
-                            return functionDef;
-                        }
+                        //method call on XML or XMLList instance
+                        return resolvedDef;
                     }
                 }
             }
+            return null;
+        }
+
+        if (iNode instanceof IIdentifierNode)
+        {
+            IdentifierNode identifierNode = (IdentifierNode) iNode;
+            IDefinition resolvedDef = identifierNode.resolve(project);
+            if (resolvedDef != null && isXMLish(resolvedDef.getParent(), 
project))
+            {
+                if (resolvedDef.isPrivate() || resolvedDef.isProtected())
+                {
+                    //private/protected member inside the XML or XMLList class
+                    return resolvedDef;
+                }
+            }
+        }
+        if (iNode instanceof IMemberAccessExpressionNode)
+        {
+            IMemberAccessExpressionNode memberAccess = 
(IMemberAccessExpressionNode) iNode;
+            IExpressionNode nameNode = memberAccess.getRightOperandNode();
+            return resolveXML(nameNode, project);
         }
         return null;
     }

Reply via email to