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 2019/12/02 18:32:52 UTC

[royale-compiler] branch develop updated: BaseTypedDefinitionNode: fixed ClassCastException in getTypeName() when type is a namespace access expression (references #100)

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 e231d74  BaseTypedDefinitionNode: fixed ClassCastException in getTypeName() when type is a namespace access expression (references #100)
e231d74 is described below

commit e231d7480bf6d86fa09905ef12ba0ad21ee0d80b
Author: Josh Tynjala <jo...@apache.org>
AuthorDate: Mon Dec 2 10:32:44 2019 -0800

    BaseTypedDefinitionNode: fixed ClassCastException in getTypeName() when type is a namespace access expression (references #100)
---
 .../internal/tree/as/BaseTypedDefinitionNode.java  | 25 +++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/BaseTypedDefinitionNode.java b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/BaseTypedDefinitionNode.java
index 0deb864..046aa34 100644
--- a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/BaseTypedDefinitionNode.java
+++ b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/as/BaseTypedDefinitionNode.java
@@ -31,8 +31,10 @@ import org.apache.royale.compiler.internal.definitions.SyntheticBindableSetterDe
 import org.apache.royale.compiler.internal.scopes.ASScope;
 import org.apache.royale.compiler.internal.scopes.FunctionScope;
 import org.apache.royale.compiler.parsing.IASToken;
+import org.apache.royale.compiler.tree.as.IExpressionNode;
 import org.apache.royale.compiler.tree.as.IIdentifierNode;
 import org.apache.royale.compiler.tree.as.ILanguageIdentifierNode;
+import org.apache.royale.compiler.tree.as.INamespaceAccessExpressionNode;
 import org.apache.royale.compiler.tree.as.ITypedNode;
 import org.apache.royale.compiler.tree.as.ILanguageIdentifierNode.LanguageIdentifierKind;
 
@@ -124,7 +126,28 @@ public abstract class BaseTypedDefinitionNode extends BaseDefinitionNode impleme
      */
     public String getTypeName()
     {
-        return hasExplicitType() ? ((IIdentifierNode)typeNode).getName() : "";
+        if(hasExplicitType())
+        {
+            IIdentifierNode identifierNode = null;
+            if(typeNode instanceof IIdentifierNode)
+            {
+                identifierNode = (IIdentifierNode) typeNode;
+            }
+            else if(typeNode instanceof INamespaceAccessExpressionNode)
+            {
+                INamespaceAccessExpressionNode namespaceAccess = (INamespaceAccessExpressionNode) typeNode;
+                IExpressionNode rightOperandNode = namespaceAccess.getRightOperandNode();
+                if (rightOperandNode instanceof IIdentifierNode) 
+                {
+                    identifierNode = (IIdentifierNode) rightOperandNode;
+                }
+            }
+            if (identifierNode != null)
+            {
+                return identifierNode.getName();
+            }
+        }
+        return "";
     }
 
     public boolean isVoidType()