Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: pkg/compiler/lib/src/constants/expressions.dart

Issue 2094273002: Fix evaluation of != (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: dartfmt Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_evaluate_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/constants/expressions.dart
diff --git a/pkg/compiler/lib/src/constants/expressions.dart b/pkg/compiler/lib/src/constants/expressions.dart
index 2deb866175d19f5a9d5adf3fd87a243db8db4a12..922ae068073ade58b01a79f842cda00232558377 100644
--- a/pkg/compiler/lib/src/constants/expressions.dart
+++ b/pkg/compiler/lib/src/constants/expressions.dart
@@ -870,9 +870,18 @@ class BinaryConstantExpression extends ConstantExpression {
@override
ConstantValue evaluate(
Environment environment, ConstantSystem constantSystem) {
- return constantSystem.lookupBinary(operator).fold(
- left.evaluate(environment, constantSystem),
- right.evaluate(environment, constantSystem));
+ ConstantValue leftValue = left.evaluate(environment, constantSystem);
+ ConstantValue rightValue = right.evaluate(environment, constantSystem);
+ switch (operator.kind) {
+ case BinaryOperatorKind.NOT_EQ:
+ BoolConstantValue equals =
+ constantSystem.equal.fold(leftValue, rightValue);
+ return equals.negate();
+ default:
+ return constantSystem
+ .lookupBinary(operator)
+ .fold(leftValue, rightValue);
+ }
}
ConstantExpression apply(NormalizedArguments arguments) {
« no previous file with comments | « no previous file | tests/compiler/dart2js/constant_expression_evaluate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698