Commit Graph

34 Commits

Author SHA1 Message Date
Konstantin Shcheglov c13752442c Fix isNullable / isNonNullable, expand tests.
This addresses the issue in a previous CL.
https://dart-review.googlesource.com/c/sdk/+/106620/3/tests/language_2/nnbd/static_errors/equals_parameter_made_nullable_at_invoke_test.dart#30

Change-Id: Ib510ddbfe42c8e6d7cb0c4793a30e050b7e56bd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106962
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2019-06-24 16:53:36 +00:00
Konstantin Shcheglov a5d6b81da8 Use flow analysis to report potentially non-nullable local variables that are used before definitely assigned.
Not done yet:
1. Switching all unit tests to `performFlowAnalysis()`.
2. Updating the error code and renaming tests.
3. Writing more language_2/ tests.

R=brianwilkerson@google.com, paulberry@google.com

Change-Id: I0936f2daa4ab1cd91edeaca3eef9544eced5b443
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106982
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-06-23 22:08:43 +00:00
Konstantin Shcheglov 32df04a5ef Fix nnbd/syntax/required_modifier_error_test
There were compilation errors reported because of missing default
values for non-required optional non-nullable parameters.

R=brianwilkerson@google.com, danrubel@google.com

Change-Id: If0454988219a7fece317c86124a81a2a8ce8bea4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106963
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Dan Rubel <danrubel@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2019-06-21 17:29:17 +00:00
Konstantin Shcheglov 85a4fdb81a Report an error when a non-nullable top-level variable is not initialized.
Change-Id: I2e5e33c01d5f2c10d41b7e2f76e93eaacadffff6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106762
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-20 18:25:11 +00:00
Konstantin Shcheglov 3c596e802b Report an error when a potentially non-nullable local variable is not initialized.
R=brianwilkerson@google.com, paulberry@google.com

Change-Id: Ie1d148ff584c202edc334659eeb4f792bb8773d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106620
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-19 18:07:56 +00:00
Mike Fairhurst 2f65830aeb Add null checks for spread operator
Change-Id: Ib3b0f46643a24e22e0344a4505743518f885e9e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102501
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-06-12 20:58:03 +00:00
Mike Fairhurst c388c263b0 Fix potentially-nullable test case
Change-Id: Ieb3d192d273b89666b8d00affe1279ada07dc384
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104945
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-06-05 07:04:21 +00:00
Brian Wilkerson 2e5cc24b8f Fix bugs in a couple of language tests
Change-Id: I601f1dafa10b9553ad4e08bad3232a896bf52aa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104843
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-06-04 17:06:05 +00:00
Mike Fairhurst 55d3bbf13f Promote parameter of == to nullable when invoked.
This is required because otherwise

Object() == null

requires the type signature of Object.operator==(Object o) to be
changed to Object.operator==(Object? o). Which I don't think is the
behavior we want.

Confirmation that this CL is correct has been sent to the language
team. I recommend we land, which will unblock my subtyping CL, and
roll back/readdress later if need be.

Change-Id: I498f9870e7128b2cac3012fff0cb1ab50fcc8df7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/104344
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2019-06-04 00:36:24 +00:00
Paul Berry 0e5d18f281 Ensure that nullability promotion of the Null type yields Never.
Change-Id: I2232f80bbf5c8a9e51f305a603c06ca2b3ad8aea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103573
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-05-24 14:57:15 +00:00
Mike Fairhurst 704446d159 Disable implicit casts but keep dynamic casts when NNBD enabled
Change-Id: Ia0a3271c9137bc8c7fa4cdbd469cf93d9453b69c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/103405
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-05-23 23:41:52 +00:00
Mike Fairhurst 6457ac1d4b Test potentially-nullable access errors
Change-Id: Ia166dbb6fb353120e30555f60b7bea186537b05b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102242
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-05-22 03:17:00 +00:00
Mike Fairhurst a3073fc581 check null condition in assert
Change-Id: I4de11a7de3e5106ce9d5fbaf89d0b0965d637b08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102221
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-05-14 22:24:34 +00:00
Mike Fairhurst b91a4f5423 [analyzer] Resolve methodName staticType when Function to check Function?
Change-Id: I85d43821d4b792c269f386616dcc21d144772c5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102201
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-05-10 21:45:29 +00:00
Mike Fairhurst 1a9d38be41 Fix improper unchecked_nullable test cases
Change-Id: I31aa8f1f53b8960550b9ab8d8cc63f670a20558b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/102220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-05-10 19:30:38 +00:00
Mike Fairhurst 536ecbac7b Add language 2 tests for null access errors
Change-Id: Icde35448c183a3b9311811aab388909d17e36ceb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101461
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-05-09 18:59:11 +00:00
Mike Fairhurst a8b6e18b62 Resolve x ?? y as LUB(X!, Y) instead of LUB(X, Y).
Change-Id: I081d8ec153916fb37e2a949d9fa85a6ea778438e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/92390
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Auto-Submit: Mike Fairhurst <mfairhurst@google.com>
2019-05-07 16:34:17 +00:00
Brian Wilkerson 821c75c584 Update a test comment
Change-Id: I6bb053a128a689d35ae1c21b29c6a7e8bb869fad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101321
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-05-06 21:19:20 +00:00
Mike Fairhurst 36c315eacc [analyzer] resolve x?.y to return T?
Change-Id: I3ef319621753364b8d70e79b2ab32d7ec9c1e8d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/92383
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
2019-05-06 21:09:39 +00:00
Brian Wilkerson dbe80f3397 Add tests for late and final variables without an initializer
Change-Id: I65c40b9e994e602f6133e100d0e8896cb9dce75c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101071
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-05-03 14:51:54 +00:00
Brian Wilkerson b8fb787994 Add a test for uses of the default List constructor
Change-Id: I3b1452186e00f930d5da7c64f3a64f08cd6f4589
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101066
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-05-02 20:46:55 +00:00
Brian Wilkerson 36b2520ca9 Add a test of creating a subtype of Never
Change-Id: I9d28868667667cca5eb122e33226b21850b062bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/101067
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-05-02 17:53:59 +00:00
Brian Wilkerson b83902d51b Add a language_2 test for missing arguments related to required named parameters
Change-Id: I4d08c5a7d7bd7950fab001281f26f2e838335339
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100724
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-04-29 21:19:08 +00:00
Dan Rubel f82000dfb1 pre-nnbd modifier as identifier tests
Change-Id: If44d1b0ac3279124e81e9c34e20f7bd9d399d1ab
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-04-24 21:29:13 +00:00
Dan Rubel 174395a49e NNBD "late" modifier language_2 tests
Change-Id: Iffcd2ef8042576bcfc195ab72f2743f2c3e7be07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100261
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2019-04-23 20:58:31 +00:00
Brian Wilkerson b4d17f2eee Add diagnostics related to default values
Change-Id: I4b30580e34fbf302a53778010fada54a2e100409
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99887
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2019-04-23 17:16:50 +00:00
Dan Rubel 293c0f42f7 NNBD "required" modifier language_2 tests
Change-Id: I2c0d53fd321dea7ed74cf9fac422ec32f9dea641
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/100260
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
2019-04-23 15:28:12 +00:00
Paul Berry 17db9f986a Simplify type tests in nullable_type_ambiguous_test.dart
Change-Id: I6612a83550acf5f1920bb0467425cfb2977ea2e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99882
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-04-22 18:50:11 +00:00
Brian Wilkerson 836efd6520 Add a language_2 test for having an invalid type in an on clause
Change-Id: Ia073e6a85f6f5cc54ecb45ab5d4e11e7976c3134
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99701
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-04-17 18:35:20 +00:00
Paul Berry 37285467db Improvements to null_assertion_ambiguous_test
Change-Id: I164d0815262d9c861c3b4ad3532808409004ea0a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99660
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-04-17 15:36:26 +00:00
Paul Berry bc99f1ca28 Test a few more uses of the nullable type decorator
Change-Id: I902caac00961514637b77f70200103618662b325
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99621
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-04-17 12:15:35 +00:00
Paul Berry 4b19ca1489 Add language_2 tests for NNBD null-assertion operator (!)
Change-Id: I06ffbfae376210ca0428181f567be3702defbe5a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99185
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-04-16 15:16:44 +00:00
Brian Wilkerson 0314d86af4 Add errors when a nullable type is used as a supertype
Change-Id: I82471ba67dd74db6425bb2081bd761eb2b490333
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99284
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2019-04-12 21:13:21 +00:00
Paul Berry d81783ff5f Begin writing language_2 tests for NNBD.
These tests validate simple uses of trailing `?` syntax, and exercise
the ambiguous cases mentioned in the draft spec.

Change-Id: If2526c7f4c898495d667d7e16a2005bd8432f8df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99183
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2019-04-12 12:42:48 +00:00