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

Unified Diff: compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java

Issue 11428131: More co19 triage. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years 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
Index: compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
index 9974915e42728d147fef43ae1dd708d88881e87b..433f8f940a298497ed042cea1745a2018ebd6dea 100644
--- a/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/resolver/CompileTimeConstantAnalyzer.java
@@ -52,6 +52,7 @@ import com.google.dart.compiler.common.HasSourceInfo;
import com.google.dart.compiler.type.Type;
import com.google.dart.compiler.type.TypeKind;
+import java.math.BigInteger;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -177,6 +178,9 @@ public class CompileTimeConstantAnalyzer {
return type;
}
Element element = node.getElement();
+ if (Elements.isFunctionIdentical(element)) {
+ return boolType;
+ }
if (element != null) {
type = element.getType();
if (type != null && TypeKind.of(type) != TypeKind.DYNAMIC) {
@@ -274,8 +278,10 @@ public class CompileTimeConstantAnalyzer {
case DIV:
checkMathExpression(x, lhs, rhs, lhsType, rhsType);
break;
- case MOD:
case TRUNC:
+ reportExceptionIfZeroLiteral(x, rhs);
+ // pass-through
+ case MOD:
if (checkNumber(lhs, lhsType) && checkNumber(rhs, rhsType)) {
rememberInferredType(x, intType);
}
@@ -295,6 +301,16 @@ public class CompileTimeConstantAnalyzer {
}
return null;
}
+
+ private void reportExceptionIfZeroLiteral(HasSourceInfo target, DartExpression e) {
+ if (e instanceof DartIntegerLiteral) {
+ DartIntegerLiteral literal = (DartIntegerLiteral) e;
+ if (literal.getValue().equals(BigInteger.ZERO)) {
+ context.onError(new DartCompilationError(target,
+ ResolverErrorCode.CONSTANTS_EVALUATION_EXCEPTION));
+ }
+ }
+ }
private void checkMathExpression(DartBinaryExpression x,
DartExpression lhs, DartExpression rhs,

Powered by Google App Engine
This is Rietveld 408576698