Commit Graph

10502 Commits

Author SHA1 Message Date
Konstantin Shcheglov b16e402fb9 Prepare for replacing PackageBundle with PackageBundleReader.
There are clients in google3 that import package:analyzer/src/summary/idl.dart
to use PackageBundle. We cannot make changes to idl.dart, so this
CL introduces a new file that we can change, and in the binary format CL
we will replace the exported PackageBundle class with a new class for
the binary format.

Change-Id: Iee89c784a2812bcdeefaef1c122ac8d8533665fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174080
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-26 05:13:44 +00:00
Sam Rawlins 4a206e4108 Analyzer: Report invalid instance access from closure within factory
Fixes https://github.com/dart-lang/sdk/issues/43610

Change-Id: Ie9728d375d01ff8c02831befd5fe04b9f5596e35
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174020
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-25 23:53:08 +00:00
Paul Berry e047dd60d6 Ensure that function elements inside local variable elements have unique locations.
Fixes #44216.

Bug: https://github.com/dart-lang/sdk/issues/44216
Change-Id: I5ccf8bb5f90396eabfec470a289a193d2aef16ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173881
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-25 13:39:04 +00:00
Brian Wilkerson c6126c34e9 Suggest previously missed type parameters
Change-Id: I09361984b7a58a281769e5feb04aeb1656620237
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173880
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
2020-11-25 00:13:49 +00:00
Sam Rawlins e33307fd41 Analyzer: account for parentheses when examining enum switch cases
Change-Id: I1752140bf4f96b45fedf787c3805a8464b6b0720
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-23 16:02:48 +00:00
Keerti Parthasarathy 416c06f19b Add a method to clear all artifacts in FileResolver
Change-Id: I420e1de8f873d350e3d90e23536eaa10770d25f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173280
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2020-11-23 07:15:45 +00:00
Sam Rawlins ef39baee37 Analyzer: Don't report all optional parameters on private ctors as unused
Fixes https://github.com/dart-lang/sdk/issues/44268

Change-Id: Ie0f3b004de2761145b7f8acffc3aa82b59a0aea2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/173420
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-21 22:08:43 +00:00
Sam Rawlins 19a96e4d5e Analyzer: override element type in ExportDirective and ImportDirective
This reduces the number of explicit casts needed for null safety.

Change-Id: I8ad0ab9cddbbe81e5fbf66b95ae4ae1cb57efebc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172743
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-20 15:22:46 +00:00
Konstantin Shcheglov 12cb02528b Issue 44248. Don't report MISSING_DEFAULT_VALUE_FOR_PARAMETER for external functions.
Bug: https://github.com/dart-lang/sdk/issues/44248
Change-Id: I31d2b6ea8efdf0ce47533d4288b3dcd41d113a2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172901
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-19 18:28:24 +00:00
Konstantin Shcheglov 590c4c4b30 PackageBuildWorkspace should stop at the first pubspec.yaml found, don't go up.
Change-Id: I1b996b34055d6887816313d333175869f570ada1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-19 08:08:15 +00:00
Konstantin Shcheglov 3dc16b2ad1 Improve test for inferencing operator== parameter type.
See https://dart-review.googlesource.com/c/sdk/+/124284
See https://github.com/dart-lang/language/issues/569

Change-Id: Idbd54bd33b70b22036e23364df4984ae92a55d04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172686
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-18 01:24:29 +00:00
Keerti Parthasarathy ed5f235c52 Fix windows test failure
Change-Id: I9700e4f86eaecd3bd003016fa2bb5a9ec8eaa417
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172462
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2020-11-17 17:11:08 +00:00
Keerti Parthasarathy 6b64d52de1 Add a method to remove unused FileState's.
Change-Id: I6e4644b48245c634cc31a6f32b19be68fd72786b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171981
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2020-11-17 04:34:00 +00:00
Nate Bosch aaf13b5247 Update to the latest package:yaml
Expand the range allowed by the dep from `package:analyzer`.

Switch dependencies to `any` for the packages which are `publish_to:
none`. The actual constraints aren't useful in these packages since they
are always pinned exactly by DEPS and so we can't trust they are kept up
to date.

Change-Id: Ibd937e8646574d49105f4dd0de2529e7ab30862a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172380
Auto-Submit: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2020-11-16 22:16:50 +00:00
Konstantin Shcheglov bb6714c051 Issue 44220. Fix for NPE when checking for INVALID_REQUIRED_* for GenericFunctionType.
Bug: https://github.com/dart-lang/sdk/issues/44220
Change-Id: I7a88a8b34fbda140ab12e6861c0b00a5e5c420b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172360
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-16 22:06:40 +00:00
Brian Wilkerson c88f99b0b7 Initial support for code completion in yaml files
Change-Id: I21276fe32d1c0d8525980edf3b1a5e93de5ae572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172024
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2020-11-16 16:26:36 +00:00
Sam Rawlins 6f77ac032b Remove use of deprecated package_config libraries.
Fixes https://github.com/dart-lang/sdk/issues/44116

Change-Id: I6d429fd31955aecefda01dab55dace922e4e46af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171880
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-14 01:11:16 +00:00
Konstantin Shcheglov d1cc9b6f27 Prepare to publish analyzer 0.41.0 and _fe_analyzer_shared 13.0.0.
Change-Id: I26118cd7bac02e649e64df7cd0b93c2203e2f954
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-14 00:26:54 +00:00
Sam Rawlins 8b587b2bd6 Analyzer: prepare summary/ tests will null checks and late hints
Change-Id: Iaed59b5283a4b74a77429aef6381f364981161ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171963
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-13 23:57:14 +00:00
Konstantin Shcheglov 861879fad4 Issue 44196. Change ExtensionElement.displayString to the empty string for unnamed extensions.
Bug: https://github.com/dart-lang/sdk/issues/44196
Change-Id: Idcd6b2caa6efa37350a518d229768e9ab3e24599
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172060
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-13 21:44:24 +00:00
Janice Collins 4bf621d512 Add triage instructions to the root of pkg/analyzer.
This synthesizes our triage discussion and the priorities I wrote in
a separate document into a markdown file in pkg/analyzer, as discussed.

Change-Id: I11d17d8b6a7b1cb281ce4649673039869ae8fb9a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/172062
Reviewed-by: Devon Carew <devoncarew@google.com>
Commit-Queue: Janice Collins <jcollins@google.com>
2020-11-13 21:16:04 +00:00
Paul Berry 7d3bc4862d Rename pkg/analysis_tool to pkg/analyzer_utilities.
It's no longer just for the tools in the `tool` directory; it also
contains test utilities for use by the analyzer and related packages.

Change-Id: I0f8cf57f24ea7aad8e2177e43ee2bcb2ab3030da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171704
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-13 17:46:30 +00:00
Erik Ernst f3ffe6dac6 [analyzer] Adjust several visitors
This CL adjusts several visitors to visit `type` rather than
`functionType` of `GenericTypeAlias`. This is needed because
`functionType` is now a view on `type`, and the former will be null
in some cases such that the underlying `type` is incorrectly ignored.

Here are the locations not yet modified in this manner:

Visitors:
  ResolvedAstPrinter
  AstBinaryWriter
  BestPracticesVerifier

Non-visitors:
  TypeAliasSelfReferenceFinder._sanitizeGenericTypeAlias, _Finder.genericTypeAlias
  VarianceBuilder._genericTypeAlias
  NamedTypeBuilder._getRawFunctionType,
  LinkedUnitContext.getGeneticTypeAliasFunction
  _File._buildFileDeclarations
  _LibraryBuilder._addGenericTypeAlias

analysis_server, visitors:
  _LocalBestTypeVisitor

analysis_server, non-visitors:
  InlineTypedef.compute
  DartUnitOutlineComputer._newGenericTypeAliasOutline
  Files: completion_metrics (about 3 locations in here).

It would be great if I could get some feedback on these: Which ones
are most urgent? Will we keep any of them unchanged?

Change-Id: Ifd55c19571d84bb7ec004b65c5f1f22f3b22cb5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171586
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-13 08:21:15 +00:00
Brian Wilkerson 236399ee5e Fix a typo that caused part of the documentation to be dropped
Change-Id: Ie685e019d6df60ba7d336b550e5c1cc1efbd6f68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171810
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-11-13 00:53:55 +00:00
Devon Carew 2ba123b86e [analysis server] remove the --file-read-mode cli option for the analysis server
Change-Id: I279233cd0b7ec09a7d2fdcd50837552f56f2584d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171763
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-11-12 21:42:50 +00:00
Devon Carew e7647f2cf2 Revert "[analysis server] remove the --file-read-mode cli option for the analysis server"
This reverts commit 1caee4d1fd.

Reason for revert: This breaks google3 - we need to update the linter's use of the analyzer API.

Original change's description:
> [analysis server] remove the --file-read-mode cli option for the analysis server
>
> Change-Id: Id07e3655cb4bcfc462ada0db8257e7cf584272f5
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171101
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Commit-Queue: Devon Carew <devoncarew@google.com>

TBR=devoncarew@google.com,scheglov@google.com,brianwilkerson@google.com

Change-Id: I68294ad8b565a94aa098e65276b78e9745eec5a5
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171640
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-11-11 20:10:41 +00:00
Devon Carew 1caee4d1fd [analysis server] remove the --file-read-mode cli option for the analysis server
Change-Id: Id07e3655cb4bcfc462ada0db8257e7cf584272f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2020-11-11 19:30:23 +00:00
Paul Berry cd05ad0009 Share and improve implementation logic of verify_tests_test.dart
This CL unifies the implementations of `verify_tests_test.dart` found
in packages `analysis_server`, `analyzer`, and `analyzer_plugin`.  It
also enhances the functionality of the tests by having them detect
both missing and extra imports in `test_all.dart` files.

This should make it easier to re-use this logic in other packages,
such as `nnbd_migration`.

Change-Id: Id344eeb4ad514461cda622495651b1339f379022
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-11 18:09:18 +00:00
Paul Berry 596198fb74 Share logic of package_root.dart
This CL unifies the implementations of `package_root.dart` found in
packages `analysis_server`, `analysis_server_client`, `analyzer`, and
`analyzer_plugin`.

This should make it easier to re-use this logic in other packages,
such as `nnbd_migration`.

Change-Id: I0da44edb379b8e929dd0b1c16a6989c1e9418acb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171260
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-11 18:09:18 +00:00
Sam Rawlins da92120968 Remove usage of Parser statics
Change-Id: I0bf517f77c09adbc97eac597f381428e4f1bd118
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171623
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-11 18:01:12 +00:00
Sam Rawlins dc48399320 Analyzer: Introduce explicit casts required by null safety, in generated/
Change-Id: I7c7ad0abd906caf47fe9900b09b23e24b53cd4f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171441
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-11 17:33:53 +00:00
Nate Bosch 7ddbd262d0 Pass URI to sourceUrl in package:yaml
An upcoming breaking change will change the static type from `dynamic`,
and at runtime allowing either `String` or `Uri`, to having a static
type of `Uri`.

https://github.com/dart-lang/yaml/issues/97

Change-Id: I0abd4c99c0cb2ff3fa220ffd5e30cc5cb683516c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/171440
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Nate Bosch <nbosch@google.com>
2020-11-11 16:01:52 +00:00
Erik Ernst 9045077b35 Add ast support for non-function type aliases
Change-Id: I5883ce6e80d451b52073f3770fbdf971e7dcf18c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170692
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-11 07:59:18 +00:00
Konstantin Shcheglov a0227f5902 Issue 44063. Report IMPORT_OF_LEGACY_LIBRARY_INTO_NULL_SAFE hint.
Bug: https://github.com/dart-lang/sdk/issues/44063
Change-Id: I69c6f84da9a9c928e177507cedb30e06a561f3f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170441
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-09 19:42:08 +00:00
Sam Rawlins ae4e13a0a0 Analyzer: prepare for migration, mostly with explicit casts
Change-Id: Ic7565765d67a6b07c9028ad70f285cf0ed9de855
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170802
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-08 18:13:47 +00:00
Sam Rawlins 594f0fd51d Analyzer: Delete unused class in source_factory_test
Change-Id: Ia46e3cec3addc18c69259587d5186f9ec078cbfa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170761
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-06 22:40:13 +00:00
Sam Rawlins 1b060fb77b Analyzer: prep for null safety with explicit casts, late hints
* `reference.hasElementFor` implies that `reference.element` is not null.
* Using `whereType` prevents an explicit cast from being needed.

Change-Id: I800f7183292ecd0bb6370a381b1d0b924b7f5a61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170744
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-06 22:07:43 +00:00
Sam Rawlins 466f2fd8a7 Analyzer: prepare some generated/ tests for null safety
Change-Id: Ieca714d8b32b7b283a8dc30dd820df07d1e64655
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170600
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-11-06 14:34:02 +00:00
Sam Rawlins 9e6486fe3f Analyzer: Make test fields late, late final, or hinted for migration.
Many fields can be late or late final, so adding hints for the migration tool.

In SnippetTester, the fields are all set in the constructor. Added a factory
constructor so the fields can be final. Renamed them to be private.

Change-Id: I559e7ba92c7c6749038630b03f67f8a77bdc704a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170406
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-05 17:45:17 +00:00
Sam Rawlins e56e5104cf Analyzer: prep file_system tests for null safety.
Fields initialized in `setUp` are late.

Variables initialized with implicit casts like:

    ClassDeclaration clazz = unit.declarations[0];

would need a cast:

    ClassDeclaration clazz = unit.declarations[0] as ClassDeclaration;

so they are updated to use var, which is more idiomatic:

    var clazz = unit.declarations[0] as ClassDeclaration;

Change-Id: I4e4ae814a814d3a4200c5078a6904dbac0a8140c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170520
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-05 17:39:37 +00:00
Sam Rawlins 60323ebce9 Analyzer: Add nullability hints to memory_file_system
The migration tool thinks the various parameters are nullable otherwise.

Change-Id: Ie24cf73bfd32ed4d4bade36a9d4fda76e1ca991a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170481
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-05 11:41:44 +00:00
Paul Berry a44fe3f778 Migration: set SDK min constraint appropriately.
As discussed in
https://github.com/dart-lang/sdk/issues/44031#issuecomment-720967259,
we want to encourage users to publish null safe packages with an SDK
min constraint matching the SDK version that was used for the
migration, e.g. `2.12.0-18.0.beta`.  However, we also want to make
sure that users doing migration via internal, dev, or bleeding edge
builds publish their null safe packages don't wind up inadvertently
publishing packages that are un-resolvable with the latest beta SDK,
so if the user is on one of those versions, we'll set their SDK min
constraint to `2.12.0-0`.

And of course, once the feature ships to stable, we'll want users to
publish their null safe packages with an SDK min constraint matching
the version in which null safety shipped to stable.

This CL implements all of that functionality, and tests it by
overriding the `version` file in the analyzer's mock SDK.

Change-Id: Ib9ed97e691271da0ed391a6c1a5fe209aa959dce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170380
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-04 18:26:57 +00:00
Brian Wilkerson b499c76516 Add documentation for some additional diagnostics
Change-Id: Ideb16c6a4c20ebb8e474e8beae841d7bd15afe13
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170362
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-11-04 17:58:32 +00:00
Konstantin Shcheglov 1726476120 Check for '!' operator when report HintCode.NULL_CHECK_ALWAYS_FAILS
Follow up for:
https://dart-review.googlesource.com/c/sdk/+/170122

Change-Id: If9b3cb1a18ecd7cf21149dbd0fda4ec209506b90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170220
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-04 03:43:25 +00:00
Jia Hao Goh 8c91d919b7 Treat integration_test/ as a directory for tests
This allows `invalid_use_of_visible_for_testing_member` to work with `@visibleForTesting` annotations when such symbols are accessed from an `integration_test/` package directory.

Bug: https://github.com/dart-lang/sdk/issues/43921
Change-Id: I530b88459060dbb05eb18d2a6de2902c88c246af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169180
Auto-Submit: Jia Hao Goh <jiahaog@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-04 00:26:15 +00:00
Paul Berry 92587baee5 Migration: fix "whereOrNull" transformation to handle complex targets.
Previously, when analyzing a call to an iterable method that could
potentially be transformed into an `OrNull` extension, such as:

  allMatches(str).firstWhere(..., orElse: () => null);

the migration tool would erroneously identify some subexpressions of
the call target (`str` in this example) as the argument supplied to
`orElse`, resulting in a crash.

This CL fixes the logic so that we use an `identical` check to verify
when we are looking at the argument to `orElse`.

Fixes #43956.

Bug: https://github.com/dart-lang/sdk/issues/43956
Change-Id: I2f4a0e81becf789cab5334d4926e014bda2772f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170162
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-11-03 22:48:17 +00:00
Konstantin Shcheglov c0c453f7f1 Issue 44029. Use the function type itself as the type of '.call'.
Presubmit in google3 looks green.
https://test.corp.google.com/ui#id=OCL:340480353:BASE:340480464:1604433051239:7c3180b

Bug: https://github.com/dart-lang/sdk/issues/44029
Change-Id: Ifc02615aa92da7ae0369ef55657cf6b0e9cdb0bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170200
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-11-03 19:59:07 +00:00
Sam Rawlins c6e4d6bcc8 Analyzer: new Hint: NULL_CHECK_ALWAYS_FAILS
This Hint reports when an expression of type Null is null-checked with `!`.
This check will always fail at runtime.

Fixes https://github.com/dart-lang/sdk/issues/43982

Change-Id: I6e2eac4f7b7720a6b9a1c02066470eb039aa9010
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170122
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-11-03 17:20:14 +00:00
Konstantin Shcheglov e8c4cc60d6 Update analyzer/CHANGELOG.md for published 0.40.6
The version 0.40.6 was published, without 0.41.0 breaking changes.
We did not want to land this CL, but we want the CHANGELOG.md

Change-Id: I667c4bf8308cc81ff608b21993e0e1b5591ab5c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170027
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-02 20:06:49 +00:00
Konstantin Shcheglov 5ac23a0c51 Use ExperimentStatus.currentVersion in MockSdk.
Change-Id: I9750278b58656d9049f689d4e1ea9b9c1f00f863
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/170025
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-11-02 17:21:59 +00:00