Two changes:
- Rather than remember to call `FlowAnalysis.finish` at the end of
each test, we now have a `_Harness.run` method that calls it
automatically.
- Variables are created using `_Harness.addVar` and their declarations
are reported to flow analysis using `_Harness.declare`. This allows
us to more easily test scenarios where a variable might be
referenced before its declaration site is encountered (which might
occur due to analyzer error recovery).
Change-Id: I0eff619840aeb057dcce8d64b6c6d23a265f81bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115421
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The crash occurred when:
- The body of the for-loop contained a write to a variable that was
declared inside the body of the loop.
- At least one variable was declared outside the for-loop.
Fixes#37983.
Change-Id: I241312e1f1c9efb879bbff93fc0ca569d8ec8370
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115262
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
The nullability on the LHS of type-parameter types is assumed to be set
explicitly, at the moment of creation of the type or some time after
that. The latter case is needed for when the bound of the corresponding
type parameter is not yet set.
The second change is that the overall nullability is not stored in a
field, but is computed as a getter.
Change-Id: Ifbe6922c3a17943dd6c4f054976516c4f6bfc96d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/115209
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Splits strong_test into 4 shards. This test took 4+ minutes locally with
the fast_strong_test and analyze_test ticking in at ~1:45. This change
makes local testing of frontend unittests take 2 instead of 4 minutes in
total.
Change-Id: Id6015de86d547b209a699b1e5196b3edad1e6977
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114501
Reviewed-by: Jens Johansen <jensj@google.com>
Dart allows the last switch case to "fall through" the end of the
switch statement. To account for this, we previously required the
caller of FlowAnalysis to calling `handleBreak` at the end of the last
switch case. (In the analyzer implementation we actually only did
this if the last case was a `default` case, but in practice there was
no observable difference).
This CL shifts the responsibility to FlowAnalysis to handle this
scenario; the caller only needs to call `handleBreak` if there is an
actual break statement present.
Change-Id: Ia0d7abb21d78205f1050873e28b30cddc5fbe344
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114547
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Responsibility for deciding whether to cancel promotions has been
moved to FlowAnalysis (previously the caller decided). This should
reduce the risk of the analyzer and front end behaviors diverging.
Also removed an unnecessary argument from
FlowAnalysis.switchStatement_end.
Change-Id: Ib015e4e360e62da7bb267057e4626acaa94e9e74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114541
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
- deprecates 'target' on LibraryBuilder, ClassBuilder, ExtensionBuilder,
TypeAliasBuilder, and TypeVariableBuilder.
- prepares for deprecation of 'target' on MemberBuilder,
VariableBuilder, and FormalParameterBuilder
Change-Id: Ic04c533eb5443c7b7c6413e48f399450d1ebe43a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113440
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Previously the client was required to create a synthetic `true`
literal. The client may still do that (it's equivalent), but it's no
longer necessary.
Change-Id: Iffa12769b542678dab6cd4b5583d7058b41aebd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114342
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
We already have an analyzer test in CFE, but because that test also
includes for instance everything that imports the front_end, kernel or
testing, we had to disable lints in that one.
This CL adds an analyzer test for CFE sorces onlyi where lints are
enabled.
Change-Id: Ic58c8c6e92f4a7962bbf5489a37f2bf95a5c095b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114067
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Add support for the `late` modifier on fields and local variables in
CFE, and `required` on named parameters When using the option
--enable-experiment=non-nullable the `isLate` and `isRequired` flags will be set
accordingly on Field and VariableDeclaration nodes.
Closes#37686Closes#37684
Change-Id: If37fc93defdabc5cc974f3f068f57752a665f4cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113036
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Runs a number of tests that are quick, currently:
* Messages test in a new fast mode which skips compilation
* The spelling tests
* The custom CFE lint test
Change-Id: I7b444e5be1cf2397d6d776aac96dd7c2ad2b302d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113320
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This will make it easier to integrate flow analysis into the migration
tool, since the migration tool has a shared code path for handling
`&&` and `||`.
Change-Id: Ibf1c7362dfeaab505a2ecf7298b2569a40fca781
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113038
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Adds Extension node to kernel/ast, currently with serialization. This
is needed to support resolution of extension methods through dill
boundaries.
Adds (Source)ExtensionBuilder for build Extension nodes and
DeclarationBuilder as common superclass of ClassBuilder and
ExtensionBuilder.
Change-Id: Id945a40452f2729f9a4f390477dd6c76f9030eaa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112256
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
This CL adds a simple spell-checker, adds a spell-checking-phase to
messages_test to spell-check our messages, adds a new test that
spell-check our dart-code and fixes a lot of spelling mistakes / typos.
Change-Id: I8943a5bd67970e9a8a775251ae0aa97799eab097
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112346
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Rename Declaration to Builder and DeclarationBuilder to TypeParameterScopeBuilder.
This prepares for the introduciton of a DeclarationBuilder superclass of
ClassBuilder, MixinDeclarationBuilder and ExtensionDeclarationBuilder.
Change-Id: I2d392372f458f39ebaea87ec10f365b822ee3841
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112088
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
From the feature specification: "If an entry contains an invalid dart
version value, #dart=arglebargle or #dart= or any other value which is
not a semantic versioning version, then tools which need the version
should report an error."
Change-Id: Ieb54dbbad6f2fecb341e27b468e3ffdf90717a7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112245
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
When we perform constant evaluation in the CFE, the async transform
runs after constant evaluation. Thus, it can no longer use const
bool.fromEnvironment("dart.vm.product") to query whether the VM is
in product mode.
Instead, it can read the product mode define directly from the
environment defines given to the CFE and generate different code
depending on the value.
Change-Id: I2aabc4a84b50a940d35d5664ff4ebdf0680ed5c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/111645
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Previously, flow analysis was using the `_identity` state for two
purposes:
1. As the "if true" state for "false" and the "if false" state for
"true".
2. As the base state for the "break" and "continue" code paths of
loops, before any "break" or "continue" statements had been seen.
For the first purpose, it is more consistent to use
`_current.setReachable(false)`. This ensures that in code disabled by
`if (false)`, promotions are not lost. For the second purpose, it is
easier to just use `null` as the base state.
There is a small behavioral change: previously in unreachable code, if
we used the `_identity` state, all variables were considered assigned;
otherwise they were considered assigned or not according to the state
of the code prior to the branch point that caused the variables to
become unassigned. Now, unreachable code consistently has the latter
behavior.
Change-Id: If77a3fcff9391b66164c0445d5242cb04c9a6b76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/112023
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Handles property access, update and method invocation on explicit and
implicit this in extension methods. Also use ReadOnlyAccessGenerator
instead of ThisAccessGenerator to handle explicit this.
Change-Id: Ifd6861b1f931f854a39ddfb9ddae35ebf6094327
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110904
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>