mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
0808d29b4e
The existing specification was underspecifying potentially constant expressions, effectively relying on evaluation to determine whether an expression was potentially constant. This change specifies potentially constant recursively using only the syntax of the expressions. Adds short-circuting to `?:`, `??`, `||` and `&&` expressions, so for `String x`, the expression `x != null && x.length > 0` is compile-time constant. The original specification requred evaluation of the latter half even when `x` is null. We can now avoid this because we can require that the unused expression is a potentially constant expression without having to check if it, or any part of it, is a compile-time constant expression. Allows `x == null` and `x != null` as compile-time constant expression independently of the type of `x`. Allows `e as T` as a compile-time constant expression. Types are more important in Dart 2, so you need a way to adjust typing in some cases, even in compile-time constant expressions. Change-Id: I02bf0b77013c3b3ced8cd46334db378787cc2d57 Reviewed-on: https://dart-review.googlesource.com/36220 Commit-Queue: Lasse R.H. Nielsen <lrn@google.com> Reviewed-by: Erik Ernst <eernst@google.com> Reviewed-by: Leaf Petersen <leafp@google.com> |
||
---|---|---|
.. | ||
language | ||
newsletter |