flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aha...@apache.org
Subject [17/50] git commit: [flex-falcon] [refs/heads/master] - try to fix implicit type conversions
Date Wed, 07 Sep 2016 22:40:18 GMT
try to fix implicit type conversions


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/796c0a37
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/796c0a37
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/796c0a37

Branch: refs/heads/master
Commit: 796c0a37f4ebb9dbde9d86395813f40bcaf3393d
Parents: 373d218
Author: Alex Harui <aharui@apache.org>
Authored: Fri Aug 12 23:59:39 2016 -0700
Committer: Alex Harui <aharui@apache.org>
Committed: Fri Aug 12 23:59:39 2016 -0700

----------------------------------------------------------------------
 .../internal/codegen/js/jx/BinaryOperatorEmitter.java   |  2 +-
 .../codegen/js/flexjs/TestFlexJSExpressions.java        | 12 +++++++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/796c0a37/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
index bb454fc..bee0ed7 100644
--- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
+++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/jx/BinaryOperatorEmitter.java
@@ -292,7 +292,7 @@ public class BinaryOperatorEmitter extends JSSubEmitter implements
             				fjs.isXMLList(mae);
             	}
             }
-            String coercion = (leftIsNumber && !rightIsNumber) ? "Number(" : "";
+            String coercion = (leftIsNumber && !rightIsNumber && isAssignment)
? "Number(" : "";
             if (isAssignment && leftDef != null && leftDef.getQualifiedName().equals(IASLanguageConstants.String))
             {
             	if (rNode.getNodeID() != ASTNodeID.LiteralStringID &&

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/796c0a37/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
index 2def937..559c1ae 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/js/flexjs/TestFlexJSExpressions.java
@@ -634,6 +634,16 @@ public class TestFlexJSExpressions extends TestGoogExpressions
     }
 
     @Test
+    public void testVisitBinaryOperatorNode_NumberPlusString()
+    {
+        IBinaryOperatorNode node = (IBinaryOperatorNode) getNode(
+                "public class B {public var b:String; public function d() { b = 10 + 'px';
}}",
+                IBinaryOperatorNode.class, WRAP_LEVEL_PACKAGE);
+        asBlockWalker.visitBinaryOperator(node);
+        assertOut("this.b = 10 + 'px'");
+    }
+
+    @Test
     public void testNamedFunctionAsArgument()
     {
         IFunctionNode node = (IFunctionNode) getNode(
@@ -1001,7 +1011,7 @@ public class TestFlexJSExpressions extends TestGoogExpressions
         IVariableNode node = (IVariableNode) getNode(
                 "var a = ((a + b) - (c + d)) * e;", IVariableNode.class);
         asBlockWalker.visitVariable(node);
-        assertOut("var /** @type {*} */ a = ((a + b) - (c + d)) * Number(e)");
+        assertOut("var /** @type {*} */ a = ((a + b) - (c + d)) * e");
     }
 
     @Test


Mime
View raw message