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 b6f42d22a MethodBodySemanticChecker: allow * type without a warning 
when assigning to boolean
b6f42d22a is described below

commit b6f42d22a334227f51158de7db7608e774bb2edf
Author: Josh Tynjala <[email protected]>
AuthorDate: Thu Sep 19 10:17:51 2024 -0700

    MethodBodySemanticChecker: allow * type without a warning when assigning to 
boolean
---
 .../compiler/internal/semantics/MethodBodySemanticChecker.java      | 6 ++++--
 compiler/src/test/java/as/ASVariableTests.java                      | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)

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 629791cda..013985adb 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
@@ -545,8 +545,9 @@ public class MethodBodySemanticChecker
              
             final boolean leftIsBoolean = SemanticUtils.isBuiltin(leftType, 
BuiltinType.BOOLEAN, project);
             final boolean rightIsBoolean = SemanticUtils.isBuiltin(rightType, 
BuiltinType.BOOLEAN, project);
+            final boolean rightIsAny = rightType == null || 
SemanticUtils.isBuiltin(rightType, BuiltinType.ANY_TYPE, project);
             
-            if (leftIsBoolean && !rightIsBoolean)
+            if (leftIsBoolean && !rightIsBoolean && !rightIsAny)
             {
                 String rightTypeName = rightType != null ? 
rightType.getBaseName() : "Non-Boolean value";
                 addProblem(new 
NonBooleanUsedWhereBooleanExpectedProblem(rightNode, rightTypeName));
@@ -2655,8 +2656,9 @@ public class MethodBodySemanticChecker
              
                 final boolean leftIsBoolean = 
SemanticUtils.isBuiltin(return_type, BuiltinType.BOOLEAN, project);
                 final boolean rightIsBoolean = 
SemanticUtils.isBuiltin(rightType, BuiltinType.BOOLEAN, project);
+                final boolean rightIsAny = rightType == null || 
SemanticUtils.isBuiltin(rightType, BuiltinType.ANY_TYPE, project);
                 
-                if (leftIsBoolean && !rightIsBoolean)
+                if (leftIsBoolean && !rightIsBoolean && !rightIsAny)
                 {
                     String rightTypeName = rightType != null ? 
rightType.getBaseName() : "Non-Boolean value";
                     addProblem(new 
NonBooleanUsedWhereBooleanExpectedProblem(returnExpression, rightTypeName));
diff --git a/compiler/src/test/java/as/ASVariableTests.java 
b/compiler/src/test/java/as/ASVariableTests.java
index c3e851859..8ef156139 100644
--- a/compiler/src/test/java/as/ASVariableTests.java
+++ b/compiler/src/test/java/as/ASVariableTests.java
@@ -120,7 +120,7 @@ public class ASVariableTests extends ASFeatureTestsBase
         };
         String source = getAS(imports, declarations, testCode, new String[0]);
         compileAndExpectErrors(source, false, false, false, new String[0],
-                "Call to isVertical is not a function.\n* used where a Boolean 
value was expected.  The expression will be type coerced to Boolean.\n");
+                "Call to isVertical is not a function.\n");
     }
 
     @Test

Reply via email to