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 046842d74962f02001852ca1d775a45eeef44b53
Author: Josh Tynjala <[email protected]>
AuthorDate: Wed Feb 4 12:51:17 2026 -0800

    MethodBodySemanticChecker: handle function type expressions as operands in 
ternary operators and logical binary operators
---
 .../semantics/MethodBodySemanticChecker.java       | 44 +++++++++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

diff --git 
a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
 
b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
index 6dfc63764..e767901de 100644
--- 
a/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
+++ 
b/compiler/src/main/java/org/apache/royale/compiler/internal/semantics/MethodBodySemanticChecker.java
@@ -141,6 +141,7 @@ import 
org.apache.royale.compiler.tree.as.INumericLiteralNode;
 import org.apache.royale.compiler.tree.as.IParameterNode;
 import org.apache.royale.compiler.tree.as.IReturnNode;
 import org.apache.royale.compiler.tree.as.IScopedNode;
+import org.apache.royale.compiler.tree.as.ITernaryOperatorNode;
 import org.apache.royale.compiler.tree.as.ITryNode;
 import org.apache.royale.compiler.tree.as.ITypedExpressionNode;
 import org.apache.royale.compiler.tree.as.IUnaryOperatorNode;
@@ -329,7 +330,48 @@ public class MethodBodySemanticChecker
             }
 
             IDefinition resolvedRightDef = null;
-            if (rightExpression instanceof IArrowFunctionBindNode)
+            if (rightExpression instanceof BinaryOperatorLogicalAndNode
+                    || rightExpression instanceof BinaryOperatorLogicalOrNode)
+            {
+                IBinaryOperatorNode binaryNode = (IBinaryOperatorNode) 
rightExpression;
+                IExpressionNode leftOperand = binaryNode.getLeftOperandNode();
+                IExpressionNode rightOperand = 
binaryNode.getRightOperandNode();
+                IDefinition resolvedLeftOperandDef = 
leftOperand.resolve(project);
+                IDefinition resolvedRightOperandDef = 
rightOperand.resolve(project);
+                if (resolvedLeftOperandDef != null && resolvedRightOperandDef 
!= null)
+                {
+                    IFunctionTypeExpressionNode leftFuncTypeExpr = 
FunctionTypeExpressionNode.createFromDefinition(resolvedLeftOperandDef, 
leftOperand, project, this.currentScope.getProblems());
+                    IFunctionTypeExpressionNode rightFuncTypeExpr = 
FunctionTypeExpressionNode.createFromDefinition(resolvedRightOperandDef, 
rightOperand, project, this.currentScope.getProblems());
+                    if (leftFuncTypeExpr != null && rightFuncTypeExpr != null)
+                    {
+                        if 
(leftFuncTypeExpr.resolveSignature(project).equals(rightFuncTypeExpr.resolveSignature(project)))
+                        {
+                            actualFuncTypeExpr = leftFuncTypeExpr;
+                        }
+                    }
+                }
+            }
+            else if (rightExpression instanceof ITernaryOperatorNode)
+            {
+                ITernaryOperatorNode ternaryNode = (ITernaryOperatorNode) 
rightExpression;
+                IExpressionNode leftOperand = ternaryNode.getLeftOperandNode();
+                IExpressionNode rightOperand = 
ternaryNode.getRightOperandNode();
+                IDefinition resolvedLeftOperandDef = 
leftOperand.resolve(project);
+                IDefinition resolvedRightOperandDef = 
rightOperand.resolve(project);
+                if (resolvedLeftOperandDef != null && resolvedRightOperandDef 
!= null)
+                {
+                    IFunctionTypeExpressionNode leftFuncTypeExpr = 
FunctionTypeExpressionNode.createFromDefinition(resolvedLeftOperandDef, 
leftOperand, project, this.currentScope.getProblems());
+                    IFunctionTypeExpressionNode rightFuncTypeExpr = 
FunctionTypeExpressionNode.createFromDefinition(resolvedRightOperandDef, 
rightOperand, project, this.currentScope.getProblems());
+                    if (leftFuncTypeExpr != null && rightFuncTypeExpr != null)
+                    {
+                        if 
(leftFuncTypeExpr.resolveSignature(project).equals(rightFuncTypeExpr.resolveSignature(project)))
+                        {
+                            actualFuncTypeExpr = leftFuncTypeExpr;
+                        }
+                    }
+                }
+            }
+            else if (rightExpression instanceof IArrowFunctionBindNode)
             {
                 IArrowFunctionBindNode arrowBindNode = 
(IArrowFunctionBindNode) rightExpression;
                 IFunctionObjectNode arrowFuncObjNode = 
arrowBindNode.getFunctionObjectNode();

Reply via email to