[Kernel] Allow invalid expressions in constant contexts

A simple solution is to leave them unevaluated.

Change-Id: Ic7d1237452a387180ec12f23b3a4030ff64f061d
Reviewed-on: https://dart-review.googlesource.com/c/89282
Commit-Queue: Kevin Millikin <kmillikin@google.com>
Commit-Queue: Aske Simon Christensen <askesc@google.com>
Auto-Submit: Kevin Millikin <kmillikin@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
diff --git a/pkg/kernel/lib/transformations/constants.dart b/pkg/kernel/lib/transformations/constants.dart
index ed4095a..866b795 100644
--- a/pkg/kernel/lib/transformations/constants.dart
+++ b/pkg/kernel/lib/transformations/constants.dart
@@ -817,6 +817,11 @@
     });
   }
 
+  visitInvalidExpression(InvalidExpression node) {
+    // Invalid expressions are always distinct, we do not canonicalize them.
+    return new UnevaluatedConstant(node);
+  }
+
   visitMethodInvocation(MethodInvocation node) {
     // We have no support for generic method invocation atm.
     assert(node.arguments.named.isEmpty);