The first code is HintCode.INFERENCE_FAILURE_ON_UNINITIALIZED_VARIABLE:
```dart
var a; // Hint: The type of v1 cannot be inferred without a type or initializer
dynamic b; // OK
var c = 7; // OK
```
This is currently only enabled via an analysis options file:
```yaml
analyzer:
language:
strict-inference: true
```
I could add it as a flag as well, but to start using this internally at Google,
we only need support in the analysis options file.
Bug: https://github.com/dart-lang/sdk/issues/33749
Change-Id: Id2a6afa7c3d724b44c20576c7f48869abcf4255c
Reviewed-on: https://dart-review.googlesource.com/c/93700
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
We already can store List<double>, but not `double` itself.
The LinkedConstantValue data structure I'm working on will have a
field of type `double`, so I need to support in in the generator.
R=paulberry@google.com
Change-Id: Ic5aa3a9a7266afabe6c64214fd68097fbebda4e8
Reviewed-on: https://dart-review.googlesource.com/c/93820
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
BTW, I'm in doubt about using global variable in AnalysisOption directly.
Maybe make it a writable option, like `lintRules`, so that we don't use
static data? I realize that most probably we set `lintRules` into
AnalysisOptions just because it is just convenient to separate registry
and enable rules, not because we want separation from static data.
R=brianwilkerson@google.com, pquitslund@google.com
Bug: https://github.com/dart-lang/linter/issues/1440
Change-Id: I44f5c8cdc41eaead926fbbe250063c41bd888a78
Reviewed-on: https://dart-review.googlesource.com/c/93844
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
IntelliJ had a regression for a short time, so sorting did not work.
R=brianwilkerson@google.com
Change-Id: I0b631e8061bc3139f0848492e35c583b6bfb4ec4
Reviewed-on: https://dart-review.googlesource.com/c/93747
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
As a temporary workaround, we ignore types when comparing default values for overrides.
See https://github.com/dart-lang/sdk/issues/35908 for a more detailed
explanation for why this is necessary. Once summaries properly record
types of constant values, we will be able to revert this hack.
Change-Id: I04728231338274a088656a629e303c0f1745466d
Reviewed-on: https://dart-review.googlesource.com/c/93642
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This is the first of several CLs updating the parser and its listeners
to conform to the unified collection spec:
https://github.com/dart-lang/language/pull/200
Change-Id: I7750bc4b029f3963b2df77dab3630775ce921bba
Reviewed-on: https://dart-review.googlesource.com/c/93740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Dan Rubel <danrubel@google.com>
If a method parameter is used in unconditional control flow in a way
that a `null` value would directly lead to an exception (i.e. by
dereferencing it, or by passing it to a method that requires a
non-nullable value), this is treated as implying that the method
parameter is intended to be non-nullable.
Change-Id: I4f55e4c95b3cfaee0a2ba9367b47d51083e0b7b1
Reviewed-on: https://dart-review.googlesource.com/c/93363
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This reverts commit 5d6bab4ed2.
Reason for revert: this change is API incompatible when rolling into mono-repo.
Original change's description:
> Add ExecutableElement(s) based InheritanceManager3, and switch analyzer to it.
>
> Change-Id: I9d87619e05ae769f4df6a6ba26cd7901c7c98510
> Reviewed-on: https://dart-review.googlesource.com/c/93141
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
TBR=scheglov@google.com,brianwilkerson@google.com
Change-Id: I98d478f56e8aea037cbcc8b6cb940c36edb732fd
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/93440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
These declarations are already available through the library element
model.
R=brianwilkerson@google.com
Change-Id: I9d3d274a8bf4ad28c10f04afc30fa11436cd0f6a
Reviewed-on: https://dart-review.googlesource.com/c/92848
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Fixes#35870.
Change-Id: Ie250961f12a720a4ffbfc114df55a18518bf0426
Reviewed-on: https://dart-review.googlesource.com/c/92864
Commit-Queue: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This allows LSP to translate locations to line/col ranges without re-requesting the LineInfos.
Change-Id: I59fab4d9f9de123deefd02a901ab4cc34ef8c0fb
Reviewed-on: https://dart-review.googlesource.com/c/92680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Danny Tuppeny <dantup@google.com>
Currently assuming that the language team chooses option 2 for
https://github.com/dart-lang/language/issues/156#issuecomment-460525075.
To handle the case where the user does not specify a default value,
and all call sites supply the named parameter, there are two possible
heuristics:
- assumeNullable: mark the parameter as nullable, since the implicit
default is `null`, even though the implicit default is never used.
- assumeRequired: consider the parameter to be `@required`, ensuring
that the implicit default will never be used.
I've provisionally chosen `assumeRequired` as the default behavior.
Functionality not yet implemented:
- If `@required` is already present in the source code, this should
override the heuristic; also it should not be added again.
- If the parameter is already marked as nullable in the source code,
this should override the heuristic.
- Uses of `@required` should be translated to `required`.
- If `@required` is already present in the source code, and a default
value is supplied, the default value should be removed.
- If the parameter is used in a way that demonstrates it was intended
to be non-nullable (i.e. it appears in a place in unconditional
control flow that would cause an exception to be thrown if it was
null), this should override the heuristic and cause it to be marked
as `@required`.
Change-Id: I9f2ec63787fdb6215e6075ecfcc830ed9942b8b5
Reviewed-on: https://dart-review.googlesource.com/c/92532
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Main risk in this CL is that it deviates from the void work which I'm confident is exhaustive.
Particularly, operators on void are caught by the resolver as a special kind of missing method, hopefully I put all the syntactic checks in at all the necessary places.
I also hardcoded "toString()," "hashCode." I previously had hardcoded to allow "==" checks, however, the code in ErrorVerifier was tripping over that. So now it should be good.
Change-Id: I56abb0219feb7aa143159694b688be15ba29015c
Reviewed-on: https://dart-review.googlesource.com/c/92063
Commit-Queue: Mike Fairhurst <mfairhurst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Adds an analysis options backpointer to linter contexts. With this, lint rules can
query options and conditionally support enabled language experiments.
Change-Id: I35dbfd112ed5f149dcc17b17b2edaf7420b38090
Reviewed-on: https://dart-review.googlesource.com/c/92460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>