In order to implement "why not promoted" functionality for constructor
field initializers, we will need to call
checkForFieldInitializerNotAssignable from the resolver, so that we can pass it
failed promotion information. So move it into the
ErrorDetectionHelpers mixin.
Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I95094e198a97608bf27f84cfb3cac40824a30ba4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192723
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
In order to implement "why not promoted" functionality for variable
declaration initializers, we will need to call
checkForInvalidAssignment from the resolver, so that we can pass it
failed promotion information. So move it into the
ErrorDetectionHelpers mixin, along with _checkForAssignableExpression
(which it calls).
_checkForAssignableExpressionAtType can now be private, since all of
its callers are now in ErrorDetectionHelpers.
Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I6655e3a655d330d61459692804854c89c0dcff70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192612
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
I considered doing the bigger refactor I described in the first CL, then
I realized that I can't because the constructors for `ErrorCode` are
`const`. We should still have some kind of tests, but they won't be as
complete as we might hope.
Change-Id: I02f397642a367af2823f67b90ffdca2113fdb8e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192725
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
* error codes are static and final; no need for a public getter
* lint codes are `late final` because they may be registered up until the
options are validated; the field is lazily calculated at such time.
Change-Id: I8d9c1e9ab4d69be77be49b44f62e605c3f06fd2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192561
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
* Invalid section (not a Map) under `analyzer: errors:`
* Invalid value (not a Scalar) under `analyzer: errors:`
* Invalid section (not a Map) under `analyzer: strong-mode:`
* Invalid section (not a Map) under `analyzer: optional-checks:`
Change-Id: Iad0b33d312f65af8a995677fe4e57389fea520c9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This is necessary because `whyNotPromoted` needs to be called right
after visiting a subexpression, but it's not always possible to tell
that the type of that subexpression will result in an error until more
code has been visited.
Change-Id: If44e2bb55612c1ba7996b523c3ec078d7b80c865
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This does a few optimizations to improve the performance of the analyzer
when watching for generated files:
- We do all the polling in a separate isolate.
- We detect when Bazel finished running and only poll afterwards.
- We use a batch interface and deliver all changes at once (instead of
one by one). This allows us to avoid resetting caches more often than
necessary.
I had to remove one of the larger tests and created an integration test
instead, since the code for detecting the Bazel builds relies on
`dart:io` directly (`ResourceProvider` does not expose a way to
check for symlink targets).
Since this required a bit more code, I've decided to create a separate
file for it (`bazel_watcher.dart`).
Change-Id: I6c2383e7fd4348ab8af1af639b10db519c7a2f33
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/183010
Commit-Queue: Michal Terepeta <michalt@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
* Add quotedAndCommaSeparatedWithAnd getter to List<String> extension.
This extension getter allows multiple fields to be initialized in
ctor initializers.
* Make all ErrorBuilder fields private which enabled analysis that all
could also be final.
* Refactor ErrorBuilder.code to not be `late final` by using a private
constructor and a factory constructor.
* Refactor TopLevelOptionValidator _valueProposal and _warningCode to
not be `late final` by initializing them in ctor initializers.
* Remove the TrueOrFalseValueErrorBuilder class. The class contained
no useful information and was basically a wrapper around
`reporter.reportErrorForSpan`. Calling this inline simplifies.
* Change reference in parser.dart as Analysis Server renamed it to
[_builder] when I refactored one of the fields in options.dart.
Change-Id: Ica867772fca5d3442ab754e588ec07829a822c2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191462
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
* Two extension methods were moved from analysis_server to analyzer, to replace
identical top-level helper functions in analyzer.
* Add nodes2 which returns a YamlMap with YamlNode keys.
* Privatize two static functions in Merger.
Change-Id: If54e73d6e8133bf1b2a3af809d6bb732c77ab9be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191381
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
I managed to remove 2 of ~5 calls to _elementType, as the argument
type was known to have a property, `.type`. I removed the null check
from the function, as it never needed to be used; the argument should
always be non-null. Two calls then require null checks, but this does
not change behavior, because null was never passed in there; `dynamic`
would have been returned then, and cast to FunctionType, which would
have failed.
Change-Id: I9b93a11e60e20a99ba8df4b5677e4c5796a49fcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191384
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>