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

Unified Diff: pkg/analyzer/lib/src/generated/constant.dart

Issue 1027453003: Fix constant evaluation of division. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 9 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 | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/constant.dart
diff --git a/pkg/analyzer/lib/src/generated/constant.dart b/pkg/analyzer/lib/src/generated/constant.dart
index 690adc180d7a24c62807d1163ed6369063b14c8c..365c327309c7d5cf279bf3b34390c8921df4484e 100644
--- a/pkg/analyzer/lib/src/generated/constant.dart
+++ b/pkg/analyzer/lib/src/generated/constant.dart
@@ -4049,19 +4049,15 @@ class IntState extends NumState {
NumState divide(InstanceState rightOperand) {
assertNumOrNull(rightOperand);
if (value == null) {
- if (rightOperand is DoubleState) {
- return DoubleState.UNKNOWN_VALUE;
- }
- return UNKNOWN_VALUE;
+ return DoubleState.UNKNOWN_VALUE;
}
if (rightOperand is IntState) {
int rightValue = rightOperand.value;
if (rightValue == null) {
- return UNKNOWN_VALUE;
- } else if (rightValue == 0) {
+ return DoubleState.UNKNOWN_VALUE;
+ } else {
return new DoubleState(value.toDouble() / rightValue.toDouble());
}
- return new IntState(value ~/ rightValue);
} else if (rightOperand is DoubleState) {
double rightValue = rightOperand.value;
if (rightValue == null) {
@@ -4069,7 +4065,7 @@ class IntState extends NumState {
}
return new DoubleState(value.toDouble() / rightValue);
} else if (rightOperand is DynamicState || rightOperand is NumState) {
- return UNKNOWN_VALUE;
+ return DoubleState.UNKNOWN_VALUE;
}
throw new EvaluationException(
CompileTimeErrorCode.CONST_EVAL_THROWS_EXCEPTION);
@@ -4684,7 +4680,7 @@ class NumState extends InstanceState {
@override
NumState divide(InstanceState rightOperand) {
assertNumOrNull(rightOperand);
- return UNKNOWN_VALUE;
+ return DoubleState.UNKNOWN_VALUE;
}
@override
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698