We don't support that currently and if we want to at some point in the future,
I'd rather implement it from scratch, and the current implementation tightly
couples various parts of the compiler to the `Compiler` object.
Change-Id: I6934df41bb363ea9a693a8181b5a0355774ba4b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101286
Reviewed-by: Sigmund Cherem <sigmund@google.com>
We now track member usage in terms of static, dynamic and super access
for reads, writes and invocations. The information collected during
closed world computation is now the basis for the potential member usage
in codegen, thus ensuring that we cannot conclude in codegen that for
instance a field is read dynamically when the closed world knows that
it is never read dynamically.
Closes#36516
Change-Id: I3a1cb87c71268c34bcd67e14a035d9d1be324ab0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100840
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
For resolution this is the KClosedWorld and for codegen this is the new
CodegenWorld object. This change removes the use of the world builders
after the world building has ended. It prepares for computing more of the
result data from the collected member usages.
Change-Id: I80032e3fc0e29179137b8c0380f09f68ab6fa03b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100540
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Fixes https://github.com/dart-lang/sdk/issues/34147.
The Dart language specification says we should ensure booleans are
non-null in the following (non-exhaustive) situations:
* (ternary) conditional expressions - this includes the `!` operator
since `!x` is equivalent to `x ? false : true`
* arguments to logical boolean expressions (`||` and `&&`), modulo
short-circuiting
* `if` conditions
* `for` loop conditions
* `while` conditions
* `do`/`while` conditions
With control-flow-collections enabled, this CL will also cover
conditions in `if` elements and `for` elements. Tests for these already
exist in
language_2/control_flow_collections/{if,for}_null_condition_test.dart.
Change-Id: I2ce9a30adeb16a0a68411f358f69aeca08656dab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98780
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
The .getStaticType results for NullLiteral and NullConstant are inconsistent. The former returns `const BottomType()` and the latter return `TypeEnvironment.nullType`.
To avoid this inconsistency and since `const BottomType()` is really the "unreachable" type, used for instance of for the type of a throw expression, the implementation is changed to consistently use the .nullType.
For this to work, getStaticTypeAsInstanceOf (and the equivalent dart2js implementation), and the `Type.fromStaticType` constructor in the VM type flow analysis have to special case the .nullType.
Change-Id: If6b806d4a39ef7b906275c43fa2089b9d140523b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98563
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
The constant evaluator assumed that any ConstantExpression met during evaluation of a sub expression was not an unevaluated constant. This do occur, for instance when a field is initialized to an unevaluated constant. With the change, unevaluated constants met during evaluation are themselves evaluated.
This change also fixed handling of assert initializers in unevaluated constants.
Change-Id: Id9e676f40bc829c4d234f34a74ef0ca5c4c6ec48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98348
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Tests that dart2js can handle evaluation of unevaluated constants from CFE, including handling of potential compile-time errors found during evaluation.
The CL fixes a bug in the constant evaluator where it created map literals that were not marked as constant as needed.
Change-Id: I7df77a3c68e52392a143478b3567d19e09ebe6bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98347
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
- Typed array elements are never null, but type inference sometimes
thinks they are.
- Annotated isNan and isFinite as pure.
Change-Id: I5fffd237374444db27665009cf550b26563bcf55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98046
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
Since we already have support for Block in our visitors, we can extend
them to support BlockExpression fairly easily.
co19_2 and language_2 tests still need to be unskipped, but we can't do
that until CFE respects the --enable-experiment=control-flow-collections
flag.
Change-Id: I48da19cc33dbf35c5ead3ea13266b01d3e0de959
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97820
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
There is nothing constructing a `ConstantUse` through any path with a
use kind of `Indirect`.
- Remove the kind field and the only place reading it. Treat it as
always `DIRECT`.
- Remove the unused `mirrors` and `typeVariableMirror` constructors.
- Preserve other named constructors even though they behave identically to avoid
losing context at use sites.
- Make the `hashCode` getter lazy since it is only forwarding to the `value`.
Change-Id: I69a36fac245c74794b65e617b8cdd445a937bbee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97343
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Nothing is reading this option.
- Change the option handler to ignore to avoid breaking users passing it
anyway.
- Remove the Flag constant.
- Remove the option.
Change-Id: I62f3b6ce7b3cf38ad310576b011d27ac78353fde
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97346
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Where we have an `@override` which duplicate's the super types doc
comment it is not adding anything useful and can be removed.
Also do some minor comment cleanup where feasible:
- Introduce blank lines following the first sentence to follow effective
dart guidelines.
- Change non-doc comments to use two slashes.
- Where comments were improved after being pasted, bring the improvement
to the original comment.
- Move comments where there was no comment on the super type but the
subtype comment clearly applied.
Change-Id: I61b5eca79f692641ce96c5c9d26fa3731c8e230e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97008
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
TBR=askesc@google.com
Revert "[CFE] Move constant evaluator to Fasta."
This reverts commit 845b5b2df1.
Revert "[CFE] Always call the constant evaluator by the evaluate method."
This reverts commit 91bc4ec2b9.
Revert "[CFE] Use Fasta diagnostics in the constant evaluator."
This reverts commit c7b572aa29.
Revert "[CFE] Check for null in constant evaluation"
This reverts commit e6d2751e9c.
Revert "Rename import after moving file."
This reverts commit a6e2c5eb4c.
Change-Id: Iadfe087c0110f6f331b82d990213f95d3ef4541b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/97223
Reviewed-by: William Hesse <whesse@google.com>