Commit Graph

30 Commits

Author SHA1 Message Date
Konstantin Shcheglov cf3a034210 Implement promotion via initialization in flow analysis.
Change-Id: I10a5f6bfeb5a05dd144db5212c9f31796f5a2385
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145502
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-04-30 16:26:27 +00:00
Konstantin Shcheglov d131ea4e13 Add Variable type parameter to VariableModel.
So, we can use exact type for TypeOperations, and it will be convenient
for implementing promotion via initialization.

R=paulberry@google.com

Change-Id: I5b1243d5a4ac95f92ee1d08e6ed64be09e8c8f53
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/145306
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-04-29 15:08:23 +00:00
Konstantin Shcheglov eada4d8d65 Implement Factor in flow analysis.
Bug: https://github.com/dart-lang/sdk/issues/40014
Change-Id: I8d21d3c3368495d9d0dbb1cd52317b053657a176
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144804
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-27 18:47:08 +00:00
Konstantin Shcheglov 61c8ac8b46 Issue 40088. Promote to NonNull of the declared type on assignment.
Bug: https://github.com/dart-lang/sdk/issues/40088
Change-Id: Icc2c720e24c2e6a85994497cd12bf34957d99d4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144040
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-04-21 03:01:54 +00:00
Konstantin Shcheglov a12c36dd97 Issue 41557. Support for breaks out of labeled blocks.
Bug: https://github.com/dart-lang/sdk/issues/41557
Change-Id: Ica1c6c04acf600cb20d11a195d6c6da73197733c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143889
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-04-20 16:30:56 +00:00
Konstantin Shcheglov 4814f000de Promote to NonNull of a tested type on assignment.
Bug: https://github.com/dart-lang/sdk/issues/39562
Change-Id: Id55224199f64a8f01b14937ddda6963aff24140c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143661
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-04-18 02:02:57 +00:00
Konstantin Shcheglov 44455a811c Update flow analysis unit test to declare variables assigned instead of write.
R=paulberry@google.com

Change-Id: I50f886d79eb6a916d3570fde931ab8fd85f76c6d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/143623
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-04-16 00:09:33 +00:00
Johnni Winther d68f552e70 [analyzer,cfe] Handle (un)assigned state in try-statement
This handles (un)assigned state in try-statement that do not
complete normally. In this case we could create a variable model
for an unreachable state that would be both assigned and unassigned
leading to an assertion failure.

Closes #41284

Change-Id: Id4c7689bc7c614338af3542eb342c964696fca1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/141981
Auto-Submit: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-04-01 15:46:15 +00:00
Johnni Winther 62f84880ef [cfe] Report error on missing return from non-nullable function
Closes #40520
Closes #40948
Closes #40425

Change-Id: I0aa3cfa51b410c90dd0bea963846eeb6b2e73efb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/140540
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-03-24 08:21:36 +00:00
Dmitry Stefantsov 3b6935f30e [cfe] Report NNBD warnings as errors in strong mode
Closes #40981.

Bug: https://github.com/dart-lang/sdk/issues/40981
Change-Id: I95715ab973a6f09bf7f8b4e090e5a80663cd4861
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139463
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-03-19 11:26:39 +00:00
Konstantin Shcheglov 4844fa9622 Issue 40959. Support null-shorting for cascades.
Bug: https://github.com/dart-lang/sdk/issues/40959
Change-Id: Ia7fd153debafd13ab469bbfcc3a2d1ef3feaa5f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139865
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-03-18 07:36:36 +00:00
Konstantin Shcheglov 17eec5bcde Mark variables written anywhere as not definitely unassigned.
Change-Id: Ia3fa8050eca7c7523500cb63620489cecb15f6d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/139038
Reviewed-by: Paul Berry <paulberry@google.com>
2020-03-11 19:47:44 +00:00
Konstantin Shcheglov 9a0c09ecb2 Track definitely unassigned variables.
Change-Id: Id610a133912605f9af63222f25408942420cbf1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138881
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-03-10 18:35:40 +00:00
Konstantin Shcheglov 24c8021f03 Replace initialize() with declare().
Fixes https://github.com/dart-lang/sdk/issues/38791

Change-Id: I954059160c75de91e1e32fe2f82ebfdc5569d947
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138666
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-03-09 18:24:51 +00:00
Johnni Winther 5829fc7829 [analyzer,cfe,dart2js] Add marker.options files to automate running id tests on all configurations
Change-Id: Ib5eb7f3967634721047f8dcc57b9e6c350b91a41
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136226
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-02-21 08:34:26 +00:00
Paul Berry 0399fcf6fa Flow analysis: fix shared tests to consider potential nullability instead of nullability.
No change in functionality.  Just changing the analyzer's
nullability_test.dart so that it generates the `nonNullable`
annotation for a promotion from type parameter `E` to `E&Object`.
This makes it consistent with the front end test runner behavior.

Change-Id: I9b74222257b432e361fbe46aa7d4d7070225a5e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133322
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-01-27 12:43:06 +00:00
Johnni Winther bbe5599476 [cfe] Handle promotion of nullable type variables
Change-Id: I5a58cf318bce5bc5342ac6d9f4d197d4e2f46680
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/133225
Reviewed-by: Paul Berry <paulberry@google.com>
2020-01-27 12:43:06 +00:00
Konstantin Shcheglov 020585872a Intersect promoted types in joinV().
Bug: https://github.com/dart-lang/sdk/issues/40010
Change-Id: I02299e48ab1c9305a2d29f804796182444f3d9aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/132166
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-01-17 22:31:37 +00:00
Konstantin Shcheglov 58a65fe4ba Issue 40110. Update switchStatement_end() to 'isExhaustive', use for switch on enum in analyzer.
Bug: https://github.com/dart-lang/sdk/issues/40110
Change-Id: Ic17ab4562f518b7e69b78c3285b577ea3b8d1223
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/131712
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-01-17 22:07:16 +00:00
Paul Berry b6ab691389 Flow analysis: adjust nomenclature to match spec draft.
Two renames, to make the implementation more closely match
https://github.com/dart-lang/language/pull/763:

- typesOfInterest -> tested
- promotion chain -> promoted types

Change-Id: If2c0d72c81bee45ef94fc4fb04000f5c9ed84f26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130570
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-01-08 17:28:15 +00:00
Konstantin Shcheglov 36ded5cdd9 Issue 39875. Don't report unchecked nullable when resovled to an extension with nullable extended type.
Bug: https://github.com/dart-lang/sdk/issues/39875
Change-Id: I8beff226da4b301b0d2903788b44705985c89823
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129323
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-12-20 23:39:44 +00:00
Johnni Winther 904a822432 [cfe+analyzer] Use TryStatement for try/catch and try/finally in CFE
This includes an alignment of assigned variables info collection between
analyzer and cfe by always collecting assigned variables info for both
the try statement and the try block.

Change-Id: I789527adc24da025a85e73cdd98392efe7fc97bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/128407
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-12-16 13:55:50 +00:00
Konstantin Shcheglov 52dc7690ef Issue 39667. Use flow analysis in IfElement.
Bug: https://github.com/dart-lang/sdk/issues/39667
Change-Id: I4528869a8d39d1b27c0cdf21ab20173bdb0efbc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127482
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-12-07 03:32:14 +00:00
Johnni Winther 42a4442521 [cfe] Handle promotion of Null to Never
Change-Id: If784cc315e0ea179e98df45a06d4a99179e4c197
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127140
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-12-04 12:41:38 +00:00
Johnni Winther 441a17d1f9 [cfe] Fix flow analysis for type parameter promotion, initializers, switch continue and for loops
Change-Id: Ia0bbbeb7f968961846a30a31471399bef9065842
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/127003
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-12-03 14:28:48 +00:00
Johnni Winther 659b32ffc8 [cfe] Handle chained null shorting and null aware if-null set
Change-Id: I39d2448a957ca7f4f3d1f027e543f773b300ce9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/126645
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2019-11-28 12:44:55 +00:00
Johnni Winther 462a448ac8 [cfe] Integrate definite assignment, nullability and type promotion analysis
Currently not handled: null-aware and break/continue

Change-Id: I61b3ef92c974a2e98a010e091ba81cbefa0f6069
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/124127
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2019-11-06 12:28:52 +00:00
Paul Berry bb8ddfcdd6 Format definite_assignment test cases.
These were proably not formatted when they were initially written
because the formatter didn't support enough of NNBD at the time.

Change-Id: Ib2f4400081835d3a797d7e4394a069b9b122efe4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123681
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-31 15:02:03 +00:00
Paul Berry a0ee662b7b Move shared analyzer/FE integration test data into shared package.
This moves the five test suites for flow analysis along with the
constants test suite.

Note that a few files have formatting errors.  I'll fix those in a
follow-up CL.

Change-Id: Ie9bba74c7d91e49ac6c9d3c64a96be007b6a94c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123680
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2019-10-31 15:02:03 +00:00
Paul Berry 29ab43e0e2 Move flow_analysis tests into package:_fe_analyzer_shared.
Change-Id: I3f95b1124ceb5c465a88e30bd161c0a2832a9772
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123625
Reviewed-by: Jens Johansen <jensj@google.com>
2019-10-31 13:05:53 +00:00