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 84bb2f85df3928571e67fae3cc9827bd3e34c9ad
Author: Josh Tynjala <[email protected]>
AuthorDate: Mon Sep 8 13:31:01 2025 -0700

    MXMLClassNode, MXMLFunctionNode: tweak use of assertion in getValue() to 
allow a null expression to return without throwing an exception
    
    This wasn't affecting tests running in Ant, but Maven was enabling 
assertions, which caused tests for things like <fx:Class/> and 
<fx:Function></fx:Function> to fail. An assertion exception is still thrown 
when the expression is not null and not an IExpressionNode.
---
 .../royale/compiler/internal/tree/mxml/MXMLClassNode.java  | 14 ++++++++++----
 .../compiler/internal/tree/mxml/MXMLFunctionNode.java      | 14 ++++++++++----
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassNode.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassNode.java
index edfc2ff8d..58d58b546 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassNode.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLClassNode.java
@@ -30,6 +30,7 @@ import org.apache.royale.compiler.internal.tree.as.NodeBase;
 import org.apache.royale.compiler.mxml.IMXMLTagData;
 import org.apache.royale.compiler.projects.ICompilerProject;
 import org.apache.royale.compiler.tree.ASTNodeID;
+import org.apache.royale.compiler.tree.as.IASNode;
 import org.apache.royale.compiler.tree.as.IExpressionNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLClassNode;
 
@@ -70,13 +71,18 @@ class MXMLClassNode extends MXMLExpressionNodeBase 
implements IMXMLClassNode
     @Override
     public ITypeDefinition getValue(ICompilerProject project)
     {
-        assert getExpressionNode() instanceof IExpressionNode : "getValue() 
shouldn't be getting called on a non-expression MXMLClassNode";
+        IASNode expressionNode = getExpressionNode();
 
-        IExpressionNode expressionNode = (IExpressionNode)getExpressionNode();
+        if (expressionNode == null)
+        {
+            return null;
+        }
+
+        assert expressionNode instanceof IExpressionNode : "getValue() 
shouldn't be getting called on a non-expression MXMLClassNode";
 
-        if (expressionNode != null)
+        if (expressionNode instanceof IExpressionNode)
         {
-            IDefinition d = expressionNode.resolve(project);
+            IDefinition d = ((IExpressionNode)expressionNode).resolve(project);
             if (d instanceof ITypeDefinition)
                 return (ITypeDefinition)d;
         }
diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLFunctionNode.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLFunctionNode.java
index 9695ea2a7..5b0008bc1 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLFunctionNode.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/tree/mxml/MXMLFunctionNode.java
@@ -27,6 +27,7 @@ import org.apache.royale.compiler.internal.tree.as.NodeBase;
 import org.apache.royale.compiler.mxml.IMXMLTagData;
 import org.apache.royale.compiler.projects.ICompilerProject;
 import org.apache.royale.compiler.tree.ASTNodeID;
+import org.apache.royale.compiler.tree.as.IASNode;
 import org.apache.royale.compiler.tree.as.IExpressionNode;
 import org.apache.royale.compiler.tree.mxml.IMXMLFunctionNode;
 
@@ -63,13 +64,18 @@ public class MXMLFunctionNode extends 
MXMLExpressionNodeBase implements IMXMLFun
     @Override
     public IFunctionDefinition getValue(ICompilerProject project)
     {
-        assert getExpressionNode() instanceof IExpressionNode : "getValue() 
shouldn't be getting called on a non-expression MXMLFunctionNode";
+        IASNode expressionNode = getExpressionNode();
 
-        IExpressionNode expressionNode = (IExpressionNode)getExpressionNode();
+        if (expressionNode == null)
+        {
+            return null;
+        }
+        
+        assert expressionNode instanceof IExpressionNode : "getValue() 
shouldn't be getting called on a non-expression MXMLFunctionNode";
 
-        if (expressionNode != null)
+        if (expressionNode instanceof IExpressionNode)
         {
-            IDefinition d = expressionNode.resolve(project);
+            IDefinition d = ((IExpressionNode)expressionNode).resolve(project);
             if (d instanceof IFunctionDefinition)
                 return (IFunctionDefinition)d;
         }

Reply via email to