| 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,
|
|
|