Revisit existing constants in the constants transformer.
Unevaluated constants are re-evaluated, and evaluated constants are
re-canonicalized.
Change-Id: I241f6b5d734797101ab1168746a849713c104695
Reviewed-on: https://dart-review.googlesource.com/c/91230
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
diff --git a/pkg/kernel/lib/transformations/constants.dart b/pkg/kernel/lib/transformations/constants.dart
index b66629c..d0799cd 100644
--- a/pkg/kernel/lib/transformations/constants.dart
+++ b/pkg/kernel/lib/transformations/constants.dart
@@ -348,6 +348,17 @@
return super.visitStaticInvocation(node);
}
+ visitConstantExpression(ConstantExpression node) {
+ Constant constant = node.constant;
+ if (constant is UnevaluatedConstant) {
+ Expression expression = constant.expression;
+ return tryEvaluateAndTransformWithContext(expression, expression);
+ } else {
+ node.constant = constantEvaluator.canonicalize(constant);
+ return node;
+ }
+ }
+
tryEvaluateAndTransformWithContext(TreeNode treeContext, Expression node) {
final Constant constant = tryEvaluateWithContext(treeContext, node);
return constant != null ? new ConstantExpression(constant) : node;