Commit Graph

329 Commits

Author SHA1 Message Date
Paul Berry 96d3efcf48 Exclude pkg/_fe_analyzer_shared/test/constants/data_2 from analysis.
This directory contains test data that isn't expected to analyze
cleanly.

Change-Id: I130db36badad76655546de7acf8f4382c54433e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168720
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-21 19:03:34 +00:00
Johnni Winther fa6399ff81 [cfe] Add messages in preparation for enabling non-nullable by default
The added messages handle the situation in which null safety is enabled
by default but is turned off either by language version or by explicitly
passing --enable-experiment=no-non-nullable

Change-Id: Iec43daf19a80f555e838635c83542fdb243b8ed4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168647
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-21 13:51:03 +00:00
Joshua Litt 043bebcd02 [dart2js] Fixes to dart2js unit tests to support nnbd by default.
Change-Id: I440dddd34a62bfe8c0f3fd563888acb680c2b031
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168141
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-10-20 18:40:44 +00:00
Johnni Winther 137c7b6c84 [cfe] Explicitly run front_end unittest without non-nullable
This prepares front_end unittests for turning on non-nullable by default.

Change-Id: I9588a2d026ab9f5b1dcf08a140d25bd5dca3d5bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/168346
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-20 13:13:33 +00:00
Anna Gringauze f04bc85e4f Refined scope calculation in expression compiler
- make sure nested blocks scopes are visited
- make sure variable definitions do not leak beyond block scopes
- properly collect scopes for loops, if statements, constructors
- add calculation of fileEndOffsets for blocks
- save block file offsets to dill
  - update binary format version
  - change kernel readers and writers to read and write block offsets
  - change vm readers to read and block offsets for new version
- add missing fileOffsets and fileEndOffsets on functions for
  late fields
- add missing fileOffsets and fileEndOffsets on functions for
  extensions
- add errors on failures to find scope
- find libraries for private fields correctly
- add more expression compilation tests
- add test to verify fileOffsets and fileEndOffsets are set for
  SDK summary (will add full dill tests later)

Closes: https://github.com/dart-lang/sdk/issues/40278
Related: https://github.com/dart-lang/sdk/issues/34942

Change-Id: I5bc1bb645543045b689d8d61069ee77dc4ee9025
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167541
Commit-Queue: Anna Gringauze <annagrin@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-20 01:44:52 +00:00
Johnni Winther 16f7ce8e57 [cfe] Warn on null aware access on this and static members
Closes #43703
Closes #43461

Change-Id: I861462b5fcf31d5459c17cbe1604ce285c359dec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/167563
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-15 08:48:33 +00:00
Joshua Litt cbbd76ef2c [dart2js] Port deferred_loading_test to features.
Change-Id: I683f82fe1096963392f78f9dd3b640b66765b8b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166604
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-10-09 21:10:17 +00:00
Paul Berry 7a1e92a670 Ensure that assert statements promote properly in unreachable code.
Fixes #40009.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I96561a72b6ba8dd8b8b95a4d9827d195941ea038
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 18644c338b Ensure that while statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I492b465b08a0f00549e8e69390cead35af211e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry f51fb064cc Ensure that try/catch statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ie4b8809c6f37ff67891bc874c0c0ec10c70eb9fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry ef1646697c Ensure that switch statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I00a8fcf52bce131874ba6d96680b11e8bc1a549c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166640
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 2601fa6d78 Ensure that && and || expressions promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ib06449624de9320f5229957511ebaaee92c75ec8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166606
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 17ebbfcbda Ensure that labeled statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ice9b50ee6a7e9ffc32635312dc951362ff0da665
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166540
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry ce7accb828 Ensure that ?? and ?. expressions promote properly in unreachable code.
Due to https://github.com/dart-lang/sdk/issues/43725 these have to be
updated in a single atomic CL.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Ifbd5fdee6379b7cbee5ab135f72a013134b70aa1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166601
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-08 21:42:14 +00:00
Paul Berry 51c6ba0edb Introduce distinct subclasses for _SimpleContext.
Note that due to https://github.com/dart-lang/sdk/issues/43725 we
can't yet downcast to these subclasses in all cases; added a test case
that would fail if we did.

Change-Id: Idd498840484a6a4c60a0cf2f8e01092ba75e7d2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-08 17:15:55 +00:00
Johnni Winther 5a2a435b6e [cfe] Use combined member signature for override inference.
Closes #43381

Change-Id: Id3ba97d717556f807eac1115e1c3570662cab87c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166240
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-10-08 15:29:05 +00:00
Paul Berry c13f4ab08b Adjust flow analysis of for each statements for consistency with for.
The recent changes to `for` statements were necessary to ensure that
if a `for` statement causes type promotion due to an unreachable
branch without type promotion joining a reachable one with type
promotion, the type promotion would still happen properly even if the
top of the `for` statement was itself unreachable.  There is no need
for a similar change to `for each` statements, because they are simple
enough that this situation cannot arise.  But it's still worth making
the corresponding change for consistency.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: Idabf7745f04a99152e688bf050a8d80e07b004e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166520
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 20:01:34 +00:00
Paul Berry 7aa9444059 Ensure that for statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I87ea8c8cd943c0c44d795aec084e012b3e2b4496
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166500
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 20:01:34 +00:00
Paul Berry c39b1642b6 Ensure that do statements promote properly in unreachable code.
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I2c53e1171bb986784b1f0e18e35556f7d6afcb15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166320
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 18:16:52 +00:00
Paul Berry 57932cfb4f Ensure that conditional expressions promote properly in unreachable code
Change-Id: I8680b81b44be789a047238b1e2d008ff240e59c2
Bug: https://github.com/dart-lang/sdk/issues/40009
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165405
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 18:16:52 +00:00
Paul Berry 8b65c31fec Fix CFE flow analysis of conditional expressions.
It turns out we didn't have enough id test coverage to tell that we
were passing the wrong value for `conditional_end`'s
`conditionalExpression` argument.

This change fixes the call site and adds an id test that would have
caught the bug.

Change-Id: Ie99b1b7045e757ee78d72fcb435222fd27d680d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166307
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 18:16:52 +00:00
Paul Berry ed2f45d56d Ensure that if statements promote properly in unreachable code
Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I04a5af558bb70b861d92b5379a8fb84489d5c9f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165402
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 15:32:25 +00:00
Paul Berry e933e91aaa Reland "Flow analysis: promote to non-nullable on initialization"
This is a reland of 6a1c54ec30

Original change's description:
> Flow analysis: promote to non-nullable on initialization
>
> When flow analysis encounters a variable declaration of the form `T? x
> = expr;`, if the type of `expr` is `T`, then the variable is
> immediately promoted to type `T`.
>
> Fixes #43099.
>
> Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
> Bug: https://github.com/dart-lang/sdk/issues/43099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

Bug: https://github.com/dart-lang/sdk/issues/43099
Change-Id: I7530bb0f7c24674a7b500558b89d50b35e045aca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166305
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-07 13:14:55 +00:00
Paul Berry 19995ba7cd Replace flow ranalysis reachability bool with a stack.
Currently we don't push or pop anything on the stack, we just
manipulate the single value that's on the stack.  So there's no
functional change.  Logic that pushes and pops the stack will be added
in a follow-up CL.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I4deb4cbe06644a2b2c9b5e2c1dc140fb4cd805cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165145
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-07 12:13:54 +00:00
Paul Berry ab4818c251 Fix bad flow analysis unit test for restrict.
I'd always meant to test the cartesian product of possible
reachabilities for the `restrict` function.  Due to a copy/paste error
I was missing one of the four possibilities.

Change-Id: I3a99c72051e7f12afd8f345d8c2dafe92d6e2c48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/166220
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-06 21:20:27 +00:00
Johnni Winther 28c6ab316d [cfe] Report errors on incompatible getter/setter types
Closes #42702

Change-Id: I9af4b8d616c4368c9f955f658f27e581352a3cd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165806
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-10-05 21:53:42 +00:00
Johnni Winther 4c29f26fc6 [cfe] Report errors in invalid main declarations
Closes #43554
Closes #43556
Closes #43558

Change-Id: Ib3e2b891473f07bad7b4a373152be684095619b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165904
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-10-05 14:37:33 +00:00
Konstantin Shcheglov 3a59eafbe5 Include promotedBound into the TypeParameterType display string.
Change-Id: I7d34a041559875d34a66de4504b8df1b57497e55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165684
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-10-02 18:42:21 +00:00
Paul Berry 7704cc9dbe Fix flow analysis of a late initializer that is an assignment expression
Fixes #43621.

Bug: https://github.com/dart-lang/sdk/issues/43621
Change-Id: I5847e34fba9d892085dd8e388f6d96912c46eb5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165682
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-02 12:09:08 +00:00
Paul Berry d73c2b05d2 Fix FlowAnalysisDebug.isUnassigned
Change-Id: Ia655a35d53c013018d8cbb1770ca2b11820c2dd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165700
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-02 12:09:08 +00:00
Dmitry Stefantsov 0c8109c964 [cfe] Adjust error location for const constructors with late fields
Closes #43354.

Bug: https://github.com/dart-lang/sdk/issues/43354
Change-Id: Idc8f4757a5589638eb4e3ce08cda2c5afa8d5202
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165604
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-10-02 08:30:16 +00:00
Clement Skau b4f49dc255 Revert "Flow analysis: promote to non-nullable on initialization"
This reverts commit 6a1c54ec30.

Reason for revert: Triggers test failure:
https://ci.chromium.org/p/dart/builders/ci.sandbox/vm-kernel-precomp-linux-debug-x64/8247

Original change's description:
> Flow analysis: promote to non-nullable on initialization
>
> When flow analysis encounters a variable declaration of the form `T? x
> = expr;`, if the type of `expr` is `T`, then the variable is
> immediately promoted to type `T`.
>
> Fixes #43099.
>
> Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
> Bug: https://github.com/dart-lang/sdk/issues/43099
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
> Commit-Queue: Paul Berry <paulberry@google.com>
> Reviewed-by: Bob Nystrom <rnystrom@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

TBR=paulberry@google.com,scheglov@google.com,rnystrom@google.com,johnniwinther@google.com

Change-Id: I8549b48a734f527194ce11d82235b9d5c6e58185
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165564
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-10-01 08:41:15 +00:00
Paul Berry 6a1c54ec30 Flow analysis: promote to non-nullable on initialization
When flow analysis encounters a variable declaration of the form `T? x
= expr;`, if the type of `expr` is `T`, then the variable is
immediately promoted to type `T`.

Fixes #43099.

Change-Id: Ia206fe0d50e2fdd9bdf637e13c85633d8490dbcc
Bug: https://github.com/dart-lang/sdk/issues/43099
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163841
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-10-01 01:15:31 +00:00
Paul Berry 94f1c0b4eb Reland "Generate "late definitely assigned" error regardless of nullability"
This is a reland of 2d22e74e54

Original change's description:
> Generate "late definitely assigned" error regardless of nullability
>
> Change-Id: If55bd3312afa2ce87312bd4ebf31ab5ada40cc3f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164981
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

Change-Id: I2dda875039c56be93430bf8f6bdca9098141d35a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165400
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-10-01 00:44:31 +00:00
Paul Berry a4ecdfc6a2 Revert "Generate "late definitely assigned" error regardless of nullability"
This reverts commit 2d22e74e54.

Reason for revert: Broke CFE bots

Original change's description:
> Generate "late definitely assigned" error regardless of nullability
>
> Change-Id: If55bd3312afa2ce87312bd4ebf31ab5ada40cc3f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164981
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Paul Berry <paulberry@google.com>

TBR=paulberry@google.com,johnniwinther@google.com

Change-Id: I595d5bd307bba3a94aac43ef96040f8cd25e1b97
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165261
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-30 14:11:56 +00:00
Paul Berry 0d35cf733e Replace flow analysis's setReachable with setUnreachable.
The setReachable method took a bool indicating whether the new state
should be considered reachable or not, however outside of tests the
value that was passed in was always `false`.  Change to a
`setUnreachable` method taking no arguments.

This should make it easier to transition to a stack representation for
reachability.

Bug: https://github.com/dart-lang/sdk/issues/40009
Change-Id: I16a35ec3d5f44763a60e42f200a3caa619fac118
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165142
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-30 12:03:54 +00:00
Paul Berry 954ba3f31c Flow analysis: don't propagate unassigned info out of closures.
All the logic we need for handling unassigned info in the presence of
closures already happens on entry to the closure, when we use
conservativeJoin to mark any variables assigned within the closure as
potentially assigned.  We don't need any additional logic at the end
of a closure.

Fixes #43006.

Bug: https://github.com/dart-lang/sdk/issues/43006
Change-Id: Ibcaaacd5bd1d18d39be013f13a7ba771d29adce4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-30 12:02:34 +00:00
Paul Berry 2d22e74e54 Generate "late definitely assigned" error regardless of nullability
Change-Id: If55bd3312afa2ce87312bd4ebf31ab5ada40cc3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164981
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-30 11:54:54 +00:00
Jens Johansen 6d7c92f016 [CFE] Add "strong" tests of the constant evaluator
This increases our "local" coverage of the constant evaluator.
Run with something like
`pkg/front_end/test/fasta/strong_tester.dart -DupdateExpectations=true -DstressConstantEvaluator=true -DskipVm=true`
there is now almost coverage of everything (or a comment in the code
suggests that the path is probably unreachable).

Note that
`out/ReleaseX64/dart pkg/front_end/test/vm_service_coverage_constant_evaluator.dart pkg/front_end/test/fasta/strong_tester.dart -DupdateExpectations=true -DstressConstantEvaluator=true -DskipVm=true`
has erroneous misses, for instance (but not limited to) asserts.
These are caused by errors in the VM.

A follow-up CL will be created to turn on "stressConstantEvaluator" by
default and print out any sucesses in the expect files.

Change-Id: I837837be4f0487fdbe57c5107e4b3415de189177
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163060
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-09-30 07:54:32 +00:00
Paul Berry 5e8b2722c7 Fix handling of for-elements with unparenthesized bodies.
The CFE defers the final build of the body of a for-element until
after building the rest of the body.  This caused a bug: if the body
was an assignment expression, flow analysis was not picking up on the
fact that the assignment was inside the loop.

Fixed by introducing a mechanism that allows the CFE to temporarily
pop the innermost structure on the AssignedVariables stack and then
push it again.

Change-Id: I11d526302934e9283807124ebd4a23e9d3e5ec66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-29 19:27:18 +00:00
Konstantin Shcheglov 2b246127f7 Prepare to publish analyzer 0.40.4 and _fe_analyzer_shared 11.0.0.
Change-Id: I19d92bf9f107a82826c2d6d41f18315f25afc411
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/165040
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-29 18:46:27 +00:00
Paul Berry 2575008f25 Generate "late definitely unassigned" error regardless of nullability
Change-Id: I3c3244cb1042087d31c6e90acc9863369e15ad44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164801
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-29 12:38:14 +00:00
Paul Berry 0176a3d4c5 Fix flow analysis handling of late variables with initializers.
A late variable with an initializer is very similar to a function
expression, in that it may be evaluated at any time in the future
(possibly more than once, if it throws an exception), so flow analysis
models it that way.

Fixes #42990.

Change-Id: I90ed00c8fd7388145f89011628e31ff7e85a5c43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164420
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-09-28 14:40:02 +00:00
Paul Berry ca0f61fc84 Generate an error if writing to a potentially-already-assigned final var.
Change-Id: Iee4dccbc2c11290cdf56b3a95259f6401a123620
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164246
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-09-28 14:36:14 +00:00
Srujan Gaddam c990450628 [package:js] Add checks for external keyword
Checks to see if a JS interop member is correctly annotated with
the `external` keyword. If it is not, it must be one of several
exceptions to be allowed.

This CL also changes static errors to first check for `JS` and
`external` before processing the member as a JS interop member.
This makes it clearer whether a member is a JS member.

Change-Id: I412eeafbfe8773847bfb9c864e4fb9b65e2d632a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158083
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-09-25 23:30:34 +00:00
Konstantin Shcheglov b53d016f71 Prepare to publish analyzer 0.40.3 and _fe_analyzer_shared 10.0.0.
Bug: https://github.com/dart-lang/sdk/issues/43550
Change-Id: I555a958c14eb435ab6a8522e89cd90dd851da2c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-25 17:52:29 +00:00
Paul Berry def50905c2 Make flow analysis handling of is/==/??=/?. consistent with mixed mode semantics
Bug: https://github.com/dart-lang/language/issues/1143
Change-Id: Id177f8b19c15ef246f21ddd840410cddfee2e5cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163600
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-09-25 08:35:03 +00:00
Johnni Winther 2414b293e1 [cfe] Throw error on exhaustive switch and expression of type Never
This requires a change to flow analysis that does not promote
expressions to Never through is-tests and equality tests.

Change-Id: Iec2ba5b78e61d205ad21dad6f07dbdb25fc746d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163380
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-09-25 08:35:03 +00:00
Paul Berry f157b5ff80 Flow analysis: promote type X&T on initialization.
When flow analysis encounters a variable declaration of the form `var
x = expr;`, if the type of `expr` is `X&T`, then the variable is given
the inferred type `X`, but it is immediately promoted to `X&T`.

Change-Id: I2a5ffca3860ab009f0942e6efc641c1604ab6323
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-09-23 16:58:09 +00:00
Paul Berry 2366d27822 Flow analysis: add API to support promotion on initialization.
Change-Id: If0258862c22234292c461af8de9f305cebcd491d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163731
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-09-23 16:58:09 +00:00