| Index: frog/leg/compile_time_constants.dart
|
| diff --git a/frog/leg/compile_time_constants.dart b/frog/leg/compile_time_constants.dart
|
| index c481947dbd3fa7ca2d593d8a0d751e88d3948005..94c98c5f9b08edbfd6af8cfd32eb8b6b882bee4e 100644
|
| --- a/frog/leg/compile_time_constants.dart
|
| +++ b/frog/leg/compile_time_constants.dart
|
| @@ -16,6 +16,8 @@ class Constant implements Hashable {
|
| bool isList() => false;
|
| bool isMap() => false;
|
| bool isConstructedObject() => false;
|
| + /** Returns true if the constant is null, a bool, a number or a string. */
|
| + bool isPrimitive() => false;
|
| /** Returns true if the constant is a list, a map or a constructed object. */
|
| bool isObject() => false;
|
|
|
| @@ -32,6 +34,7 @@ class Constant implements Hashable {
|
| class PrimitiveConstant extends Constant {
|
| abstract get value();
|
| const PrimitiveConstant();
|
| + bool isPrimitive() => true;
|
|
|
| bool operator ==(var other) {
|
| if (other is !PrimitiveConstant) return false;
|
| @@ -877,26 +880,34 @@ class CompileTimeConstantEvaluator extends AbstractVisitor {
|
| folded = const GreaterEqualOperation().fold(left, right);
|
| break;
|
| case "==":
|
| - folded = const EqualsOperation().fold(left, right);
|
| + if (left.isPrimitive() && right.isPrimitive()) {
|
| + folded = const EqualsOperation().fold(left, right);
|
| + }
|
| break;
|
| case "===":
|
| - folded = const IdentityOperation().fold(left, right);
|
| + if (left.isPrimitive() && right.isPrimitive()) {
|
| + folded = const IdentityOperation().fold(left, right);
|
| + }
|
| break;
|
| case "!=":
|
| - BoolConstant areEquals = const EqualsOperation().fold(left, right);
|
| - if (areEquals === null) {
|
| - folded = null;
|
| - } else {
|
| - folded = areEquals.negate();
|
| + if (left.isPrimitive() && right.isPrimitive()) {
|
| + BoolConstant areEquals = const EqualsOperation().fold(left, right);
|
| + if (areEquals === null) {
|
| + folded = null;
|
| + } else {
|
| + folded = areEquals.negate();
|
| + }
|
| }
|
| break;
|
| case "!==":
|
| - BoolConstant areIdentical =
|
| - const IdentityOperation().fold(left, right);
|
| - if (areIdentical === null) {
|
| - folded = null;
|
| - } else {
|
| - folded = areIdentical.negate();
|
| + if (left.isPrimitive() && right.isPrimitive()) {
|
| + BoolConstant areIdentical =
|
| + const IdentityOperation().fold(left, right);
|
| + if (areIdentical === null) {
|
| + folded = null;
|
| + } else {
|
| + folded = areIdentical.negate();
|
| + }
|
| }
|
| break;
|
| default:
|
|
|