Commit Graph

28 Commits

Author SHA1 Message Date
Sam Rawlins 475ffb96c0 Migrator: Use pedantic 1.9.0
Change-Id: Ia53e84ac6b2f3ab0679710c14453fd65c8f9c00d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/163161
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-09-17 20:52:43 +00:00
Paul Berry 925e3fe782 Migration: detect weak-only code in conditional expressions.
This change adds the ability to detect when one branch of a
conditional expression is weak-only due to nullability.  For example,
in the following code:

  int f(int/*!*/ i) => i == null ? g(null) : i;
  int g(int j) => ...;

the call to `g` can only happen in weak checking mode.  The migrator
also now understands that j only needs to be nullable if i is
nullable.

Fixes #41555.
Partially addresses #41551.

Bug: https://github.com/dart-lang/sdk/issues/41555
Change-Id: I02c9c3072f0104db0f1a5b432fb1f2f8f06d5282
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/144120
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2020-04-20 19:09:32 +00:00
Mike Fairhurst ffc3cd6e29 [nnbd_migration] Type arguments should get uncheckable edges
Change-Id: I5940fc80e8e7f1af5e1febf7ca4f95dd6178f149
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/135629
Reviewed-by: Paul Berry <paulberry@google.com>
2020-02-14 18:57:47 +00:00
Mike Fairhurst 033422b8cf [nnbd_migration] preserve type formals in DecoratedType.withNode()
Change-Id: I44ef4374714b02a497ae0981a8de1db9e593b029
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/130181
Reviewed-by: Janice Collins <jcollins@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2020-01-06 18:06:21 +00:00
Mike Fairhurst 52d568a9ea [nnbd_migration] fix crash by composing non-null/type promotion
There were cases where types that are promoted with current type
promotion were not being promoted with improved type promotion due to
null-checks:

```dart
void f(x) {
  if (x == null) {
    return;
  }

  if (x is ...) ...
}
```

This was causing a bad state when trying to substitute type parameters
on methods if promotion usually succeeded.

Fix the crash by allowing migration to promote a non-null type to a new
type, and make that new type an intersection of the new type and
non-null.

```dart
  if (x == null) {
  } else if (x is List<int/*1*/>/*2*/) { // promote to List<int/*1*/>!
```

Change-Id: Icf9f74eb2b3eef887a29d4bfab7556ac126f49e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129540
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-12-27 19:53:46 +00:00
Paul Berry f525ddeaf3 Add/fix return types to NNBD migration tests.
This will be necessary in order to pass pedantic lints.  See
discussion in https://dart-review.googlesource.com/c/sdk/+/129325.

Change-Id: I61011a082a5401401fa1b7bb0d0bd7aed87a9d10
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/129800
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-12-27 18:13:15 +00:00
Paul Berry 6fa41ae6f9 Migration: remove _notNull* fields from EdgeBuilder.
We want to create a separate nullability node for each non-nullable
node so that instrumentation can explain to the user where it came
from.

Change-Id: Id51a3366284e8c51c466458c1c14de963cd0bd05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/125551
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-11-21 15:19:15 +00:00
Paul Berry 696a374b6f Flow analysis: properly handle the fact that ++ and -- are assignments.
Change-Id: Ie54fbf7c7c750457b2750de90c64e8ea32db15d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122730
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-24 17:57:27 +00:00
Paul Berry 8f5a45c22d Flow analysis: add support for ??=.
Change-Id: I8c99c42cf3a2560d7af3daf27ee316e22a2eb027
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122588
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-10-24 17:57:27 +00:00
Paul Berry b7911e4490 Flow analysis: add support for asserts.
Fixes #38761.

Change-Id: I6cc4adc0383cc56d99fa73ef75f728db0c56063b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122732
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-24 17:01:33 +00:00
Paul Berry 92c69f224b Flow analysis: promote on successful execution of an "as" expression.
Change-Id: I506281ab2dfe23b4b75daf795028fec979006932
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122586
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-10-23 17:02:37 +00:00
Paul Berry 8ffe04bcf7 Migration: integrate flow analysis for "is" checks.
Fixes #38340.

Change-Id: I881f71f4dbbdc75b33433bca15445b0677ef04d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117775
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-09-19 13:16:06 +00:00
Paul Berry a85b7cef95 Migration: Add support for for-each loop variables.
Change-Id: If5536394a99e4706c3916d360e7ac051e18a97f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/117772
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-09-19 13:16:06 +00:00
Paul Berry 0c3a1a986f Migration: integrate flow analysis of try/catch/finally statements.
Change-Id: I2e826fc28c8acc5abae23e318cc21ec8053251a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114552
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-08-26 21:47:18 +00:00
Paul Berry 7b2e879858 Migration: integrate flow analysis of switch statements.
Change-Id: I53fff3cd3a756484e21c5355178f211dd52de78b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114562
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-08-26 20:42:26 +00:00
Paul Berry e0c37247a2 Migration: integrate flow analysis of logical not expressions
Change-Id: Ib30d21f63e002346cd1bd08507b6ec15dcf200da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114540
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-08-26 14:00:05 +00:00
Paul Berry 9c761e1531 Migration: integrate flow analysis of if-null (??) expressions.
Change-Id: Iff78b3fe100d2014a0d9a62d70ae0d4c940b2a72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114446
Reviewed-by: Dan Rubel <danrubel@google.com>
2019-08-26 12:20:21 +00:00
Paul Berry 75b4090c35 Migration: integrate flow analysis for throw and rethrow.
Change-Id: I7a196396b09df95d4275ad019d684850a84f94be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114442
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-08-23 21:30:24 +00:00
Paul Berry 07a6b19eaa Migration: integrate flow analysis of for-loops.
Change-Id: I1b17f9d6d06d17d7f9be08226d41ae79f17dc6b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114343
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-08-23 16:19:49 +00:00
Paul Berry 1279641cdd Migration: integrate for-each loops with flow analysis.
Change-Id: I360906d9ed4c4bb3a1475323b4ca6b44dc6f90cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114000
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-08-21 22:18:24 +00:00
Paul Berry 203038ffc6 Migration: integrate flow analysis of do and continue statements.
Change-Id: I5f245046806d58b1eb850ee0b4f89dd16251bcee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113268
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-08-19 15:49:43 +00:00
Paul Berry f62531fe9e Migration: integrate flow analysis of while loops and break statements.
Support for continue statements is deferred until later, because
continue statements don't have much effect on flow analysis of while
loops.

Change-Id: I8bea5ab7669e14a70b631efbdcc3d268c965aa3d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113387
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-08-16 20:26:10 +00:00
Paul Berry e08902e476 Migration: integrate conditional expression handling with flow analysis.
Change-Id: I33c0975038caaef0c97216879c1a0d46bc55b1d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113384
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-08-16 20:26:10 +00:00
Paul Berry eb066376c4 Migration: hook up flow analysis for boolean literals
Change-Id: Ic23045615fa8dc505856db40d75f6b71849d4e61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-08-16 17:41:10 +00:00
Paul Berry a3b3dc00ca Migration: recategorize some tests.
These tests were accidentally moved into
edge_builder_flow_analysis_test.dart, but they don't test flow
analysis.  Moving them back to edge_builder_test.dart.

Change-Id: I701b8785d43c7ddb50b16ad25bd4061057638ed8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113362
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-08-16 17:41:10 +00:00
Paul Berry 4938e4564c Migration: add support for local functions and function expressions.
Change-Id: Icf089c40f219503b42aea744f043249f672b2ed6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113240
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Mike Fairhurst <mfairhurst@google.com>
2019-08-16 14:12:17 +00:00
Paul Berry 5498d4cf20 Migration: integrate assignments with flow analysis.
Change-Id: Icf5605a1dee354f8cbc58ecb645c1921fe5169c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113210
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-08-15 20:41:22 +00:00
Paul Berry 3f5f9831d8 Migration: move edge builder flow analysis tests to their own file.
Change-Id: I984cfe6a041753cdefefaa2ad12cfaf00e120b6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/113220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-08-15 17:07:40 +00:00