Commit Graph

12819 Commits

Author SHA1 Message Date
Konstantin Shcheglov 67e7c96962 Fix parser to use correct begin token, to get documentation comments from it.
Change-Id: I9505353c9c6c00082e588aced34e8151c7ab22b7
Bug: https://github.com/dart-lang/sdk/issues/51447
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284441
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-22 17:03:38 +00:00
Konstantin Shcheglov 5b55ed416f Update documentation for ByteStore.putGet(), update MemoryByteStore implementation
This brings it in sync with the existing implementation in Cider.

In Cider we cannot enfore no-putGet-when-data-exists because of possible
race condition, when data did not exist during `get` by isolate1, but
was put shortly after by isolate2, before isolate1 computed data and
attempted to `putGet`.

Change-Id: I36d9083f204be48e529e675a3f046784375f6fbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284580
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-22 17:03:09 +00:00
Sam Rawlins 61e1808e2f [analyzer] Move 5 more HintCodes to be WarningCodes, SUBTYPE_*, UNDEFINED_*, UNNECESSARY_*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I7d15e27697093ecbdb958900f57e40d01753fdb3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284541
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-22 15:24:39 +00:00
pq b0078ad057 + RECORD_TYPE_ONE_POSITIONAL_NO_TRAILING_COMMA diagnostic
See: https://github.com/dart-lang/sdk/issues/51446

Change-Id: I4ebb0a8978bd98fc658737f69b790c2039c17d52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284501
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2023-02-22 02:07:53 +00:00
Sam Rawlins e3c7b321a1 [analyzer] Trim 'Missing library' error text further
It looks like the error is currently truncated after the 100 root children and
approximately 170 reader URIs. Trimming to 50 root children and 50 reader URIs
seems quite safe. I can't claim that I foresee situations that could only be
solved by seeing the 50th URI, but I don't see any reason to pick a smaller
number.

Bug: b/267353400
Change-Id: I12ddcd7c89cfdc95faaef9feab56b6c22eee459f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284281
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jaime Wren <jwren@google.com>
2023-02-21 22:08:29 +00:00
Konstantin Shcheglov 479a98f5b5 Prepare to publish analyzer 5.6.0 and _fe_analyzer_shared 54.0.0
Change-Id: I6b36a25adfa78cb8d0534afa006daa66a6a8ed78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-21 21:26:42 +00:00
Kallen Tu 16b1c12619 [analyzer] Disallow classes to be used as mixins even inside the library.
Change-Id: I62aaf972a16cdd678f5711a41dc1652b89d0be37
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283131
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-02-21 19:32:44 +00:00
Konstantin Shcheglov a70386bfd6 Report CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE
Change-Id: I782bcf984e47162340baf96245dab8792fa3cbe0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284241
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-21 17:01:32 +00:00
Jaime Wren abaf24e10d Avoid calling ByteStore.release() with an empty set
Change-Id: I5ca8b8acc5074d34dba3d01c0841f4c755634518
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283965
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Jaime Wren <jwren@google.com>
2023-02-20 19:59:36 +00:00
Ilya Yanok 029e0cec71 Revert "Enforce current library restrictions."
This reverts commit 0c05e33836.

Reason for revert: breaks ~10% of G3 smoke suite.

Original change's description:
> Enforce current library restrictions.
>
> Mark all currently unimplementable types as `final`, or `sealed` for `num` and `final` for `Function`.
> Mark all current classes intended as mixins as `mixin class`.
>
> More additions and cleanup will follow,
> but this change should make everything keep working as today
> if we flip the switch.
>
> TEST= No new tests, very little actual change, covered by existing tests with few changes. Will add more tests when adding more modifiers.
>
> Change-Id: I40e724f823e7f88cdef186d2f73874df256e2f43
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281683
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Kallen Tu <kallentu@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ib0cb5b7ec1a8c392bbf9bf4af8dc3efc0b27991d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284187
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ilya Yanok <yanok@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-20 15:29:41 +00:00
Lasse R.H. Nielsen 0c05e33836 Enforce current library restrictions.
Mark all currently unimplementable types as `final`, or `sealed` for `num` and `final` for `Function`.
Mark all current classes intended as mixins as `mixin class`.

More additions and cleanup will follow,
but this change should make everything keep working as today
if we flip the switch.

TEST= No new tests, very little actual change, covered by existing tests with few changes. Will add more tests when adding more modifiers.

Change-Id: I40e724f823e7f88cdef186d2f73874df256e2f43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281683
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2023-02-18 12:37:40 +00:00
Konstantin Shcheglov 3f288db57e Issue 51046. Implement primitive equality.
Bug: https://github.com/dart-lang/sdk/issues/51046
Change-Id: I2190b9e36753cc5f4708597ae0b515430d2f7bf2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283440
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-18 06:22:04 +00:00
Jackson Gardner d90a06bf89 Revert "[analyzer] Move 6 more HintCodes to be WarningCodes, STRICT_*, SUBTYPE_*, UNDEFINED_*, UNNECESSARY_*"
This reverts commit 86278e3c2e.

Reason for revert: This is breaking flutter customer tests. See https://github.com/flutter/flutter/issues/120992

Original change's description:
> [analyzer] Move 6 more HintCodes to be WarningCodes, STRICT_*, SUBTYPE_*, UNDEFINED_*, UNNECESSARY_*
>
> Bug: https://github.com/dart-lang/sdk/issues/50796
> Change-Id: Ic65b01d19984874c442722de472b21701f85ee5d
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283400
> Commit-Queue: Samuel Rawlins <srawlins@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Ia2eaba6ebbbad13fe31b783b39c02b1adce322b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283923
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
2023-02-17 19:37:29 +00:00
Sam Rawlins 59d7ca176f [analyzer] Move 7 more HintCodes to be WarningCodes, INVALID_*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I7ce6ec4562352d5ed7d6f4b3d6de3316ed9271e2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283701
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-17 14:51:17 +00:00
Konstantin Shcheglov e121b1b729 Implement DartPattern.precedence
Change-Id: I6f4d3b6bd7dfa92298302ba0efaec14c926461b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283740
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-02-17 00:17:26 +00:00
Kallen Tu 3118002665 Revert "[analyzer/cfe] Report an error when declaring a mixin class with final, interface, or sealed."
This reverts commit f17e9732c5.

Reason for revert: Merged this and forgot there were dependencies that needed to be merged first.

Original change's description:
> [analyzer/cfe] Report an error when declaring a mixin class with final, interface, or sealed.
>
> Change-Id: Ia1393851dffaab55c31d04d4e81bfae83a7bd67f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283126
> Commit-Queue: Kallen Tu <kallentu@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

TBR=scheglov@google.com,johnniwinther@google.com,kallentu@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Ia339aac26ecd20aa8725cc9109919e3cbef6363b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283741
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-02-16 22:10:33 +00:00
Kallen Tu f17e9732c5 [analyzer/cfe] Report an error when declaring a mixin class with final, interface, or sealed.
Change-Id: Ia1393851dffaab55c31d04d4e81bfae83a7bd67f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283126
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-16 21:27:28 +00:00
Sam Rawlins 86278e3c2e [analyzer] Move 6 more HintCodes to be WarningCodes, STRICT_*, SUBTYPE_*, UNDEFINED_*, UNNECESSARY_*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Ic65b01d19984874c442722de472b21701f85ee5d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283400
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-02-16 14:47:49 +00:00
Johnni Winther 763edcaf86 [_fe_analyzer_shared] Support switch expressions and errors in exhautiveness id testing
Change-Id: Ic1846f7a8b56fc72a816d9b6d4b930f80974759f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283321
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-02-16 11:53:16 +00:00
Daco Harkes d5495e5b87 Reland "[analyzer/ffi] Disallow nullable struct fields"
This is a reland of commit 846fb2832e

Flutter's dependencies have been rolled.
g3 has also been rolled.

Original change's description:
> [analyzer/ffi] Disallow nullable struct fields
>
> TEST=pkg/analyzer/test/src/diagnostics/invalid_field_type_in_struct_test.dart
>
> Bug: https://github.com/dart-lang/sdk/issues/51041
> Change-Id: Id3868a633f6627ebc0f528140a640e0c1dfe34ff
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279510
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>

Bug: https://github.com/dart-lang/sdk/issues/51041
Change-Id: I91b5462b00657f41c20d45d9e59011d8ab3e8437
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283601
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2023-02-16 11:26:38 +00:00
Johnni Winther ac20881b23 [_fe_analyzer_shared] Handle record types in exhaustiveness checking
This adds support for record types in the exhaustiveness algorithm.

The original algorithm was based on that record pattern would
match fields on all types, but that is no longer the case. Instead
record patterns only match corresponding to their own type. For this
reason the testing code is updated to create record spaces in relation
to a type. For instance, when the test create a record space {x: B}, it
is know create in relation to a type, say (x: A, y: A), and the create
space will therefore have (x: *, y: *) structure where the y: component
is implicitly Top, similar to how object patterns are used.

Unlike the Dart record types used for type checking and inference, the
record types used for exhaustiveness do not take the field types into
account for its subtype relation. This is avoid conclusions like
(int i, Object o) and (Object o, int i) having no values in common because
their corresponding types (int, Object) and (Object, int) are not subtypes
of each other. Instead, the subtype relation for record types used for
exhaustiveness only use the structure of the record to determine whether
two types are related.

Note though, that fields of a record type still know the type of the field.
This is used when expanded a record type into a space; the field spaces
will be derived from the field types in this case.

Change-Id: I84735d827494bcf384fd5f419d71933830ff5d15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283182
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-02-16 00:36:01 +00:00
Paul Berry c964f14a0d Shared type analysis: add optional exhaustiveness error.
This optional error fires if patterns are enabled and the type
analyzer encounters a switch that is required to be exhaustive (i.e. a
switch expression, or a switch statement with an always-exhaustive
type), and flow analysis cannot prove that the switch is exhaustive.

This is intended to be available as a temporary workaround if we
decide to ship an early beta of the "patterns" feature before
exhaustiveness checking is sufficiently ready.  We won't enable it
unless we need to, and we won't ship the final patterns feature with
it enabled.

Change-Id: I8c4c65c21abdc32b91537b3f30e7fd86f446f571
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283060
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-15 20:18:32 +00:00
Konstantin Shcheglov b35443bfbb Issue 51403. Fix rewriting PrefixedIdentifier, into PropertyAccess, then into FuncitonReference.
Bug: https://github.com/dart-lang/sdk/issues/51403
Change-Id: Id4b74f85fdef14360120b2886daf59946e9571c8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283343
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-15 19:07:38 +00:00
Paul Berry 9a608aa7d8 Shared analysis: switch all error methods to named arguments.
This makes the unit tests clearer, since it's possible to tell the
meaning of each argument.  It also simplifies the underlying unit
testing logic that formats the errors.

Change-Id: I7212fe0c909ca0b627f8a8889621af3a62a63f00
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283132
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-02-15 15:30:18 +00:00
Johnni Winther 0937087af8 [parser] Improve error recovery for constant patterns
This allows the parser to parse constant patterns at lower precedence
level in order to recognize more expressions in this context. To
support this, _parsePrecedenceExpressionLoop special cases a few cases
that should _not_ be parsed as expression in a constant pattern context.

Closes #50996

Change-Id: I43bb0ce52d366bd2dfcf47e12eec5883402f668a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282100
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-02-15 13:49:37 +00:00
Johnni Winther d4a73e3b82 [cfe] Report errors on invalid const patterns with explicit 'const'.
Change-Id: I4f5994fd1f0d5e5289684e0da2f03720706f6d28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-02-15 10:34:28 +00:00
Konstantin Shcheglov 59d080301e Index, search, rename for pattern fields.
Change-Id: Iaeae578d18c139850664f30fc5bbc92ad95132ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283127
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-15 03:54:58 +00:00
Sam Rawlins 306029141a [analyzer] Move 4 more HintCodes to be WarningCodes, Must* and CAST_FROM_NULL*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I92df471f4882d2524b825df1bf096c5ff1131bdc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283100
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-14 23:38:30 +00:00
Paul Berry d77ea3b883 Shared analysis: clean up switchCaseCompletesNormally error.
The `numMergedCases` argument was a holdover from the old analyzer
representation of switch statements (in which cases sharing a body
were not merged); it is no longer useful.

Also, the analyzer tests in `switch_case_completes_normally_test.dart`
have been adjusted so that they no longer expect this error to be
issued when pattern support is enabled; this is consistent with the
spec (which removes this error).

Change-Id: Ia22a35b7a94ee585e0614d85012ee80b9dbc12d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283125
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-02-14 22:37:37 +00:00
Konstantin Shcheglov 2783b50f90 If a field does not exist, pretend that it does, and matches everything.
Change-Id: Ifdd297642a4588ed3620ce5d453ace52a9ce38cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283123
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-02-14 20:27:38 +00:00
Konstantin Shcheglov ee9a0a6a60 Issue 51412. Create scopes for for/if elements.
Bug: https://github.com/dart-lang/sdk/issues/51412
Change-Id: I578a1c68efef566933bbe794b722aed349d8714f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283122
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-14 19:54:37 +00:00
Konstantin Shcheglov 479f067d34 Include location line:column and snippet into index textual dumps.
Change-Id: Id20f557384c43de8c8f5e57b5779a69f2465f80c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283120
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-14 18:41:57 +00:00
Konstantin Shcheglov 4ddfa7bac5 Prepare to publish analyzer 5.5.0 and _fe_analyzer_shared 53.0.0
Change-Id: If616813aeab905026f936015d86560388aa80044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283101
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-14 18:41:48 +00:00
Konstantin Shcheglov c7c87554da Support for wildcard in exhaustiveness.
Change-Id: If130be3e4bc5e3aba0ba7b148e72e9ea36834c1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282900
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-14 17:34:39 +00:00
Johnni Winther 2b28b97e7a [_fe_analyzer_shared] Add new exhaustiveness algorithm
This adds the new exhaustiveness algorithm and uses it instead of the
old algorithm. The old algorithm is left in, for now.

Change-Id: I180934f05525aed3d4d43cd8a00bcc6e50305347
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282720
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-02-14 17:26:05 +00:00
Konstantin Shcheglov c2c059ccc5 Fix duplicate relations in index.
Change-Id: I07b7a5d971d2850d480a78412dc5b0fe0001127f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-14 17:15:47 +00:00
Ahmed Ashour f6b8713241 [analyzer] add test case
Bug #51407

Change-Id: I41cd6e68a523964898875b5558898ecbdbcca74d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282881
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-02-14 16:52:59 +00:00
Sam Rawlins 4b913b1797 [analyzer] Move 4 more Hints to be Warnings, TEXT_* and TYPE_*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: I05e7d6def39cb8c0a18f4d5685f679477d8af044
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282803
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-14 15:22:28 +00:00
Jens Johansen bedcd57656 [analyzer] Faster relative-path-if-inside-same-dir function for AbstractDartSdk.getPath
AbstractDartSdk._getPath has some "phases" trying to determine a
"dart import uri" from a File.
One of these phases checks if the given file is inside a directory that
one of the known sdk platforms is inside, thus allowing us to construct
a uri from there.
For instance if we know that `/a/b/c/d/e.dart` is called
`dart:foo/e.dart` and we’re presented with `/a/b/c/d/f.dart` we’ll
figure out that it’s called `dart:foo/f.dart`.
The code for this is very simple, but very inefficient.

This CL makes it more efficient.

This is only applicable when analyzing with the flutter platform.

The below benchmarks show a ~7 to ~33% improvement depending on what's
being analyzed. It's all done via `dart analyze` where the first run
has been discarded so everything is in cache.

Running on `rwf-materials`:

```
Before:
real    1m54.491s
real    1m55.969s
real    1m53.802s

Now:
real    1m16.348s
real    1m17.570s
real    1m17.149s

Difference at 95.0% confidence
        -37.7317 +/- 1.06819
        -32.8805% +/- 0.930855%
        (Student's t, pooled s = 0.471277)
```

Running on "flutter gallery":

```
Before:
real    0m2.836s
real    0m2.783s
real    0m2.718s

Now:
real    0m2.478s
real    0m2.492s
real    0m2.451s

Difference at 95.0% confidence
        -0.305333 +/- 0.10044
        -10.9872% +/- 3.61426%
        (Student's t, pooled s = 0.0443133)
```

Running on "flutter-wonderous-app":

```
Before:
real    0m2.019s
real    0m1.999s
real    0m1.984s

Now:
real    0m1.863s
real    0m1.821s
real    0m1.856s

Difference at 95.0% confidence
        -0.154 +/- 0.0457455
        -7.69743% +/- 2.28652%
        (Student's t, pooled s = 0.0201825)
```

Running on "flutter gallery" and "flutter-wonderous-app" at the same time:

```
Before:
real    0m3.446s
real    0m3.407s
real    0m3.431s

Now:
real    0m2.993s
real    0m2.965s
real    0m3.008s

Difference at 95.0% confidence
        -0.439333 +/- 0.0470921
        -12.816% +/- 1.37375%
        (Student's t, pooled s = 0.0207766)
```

Change-Id: I13e81e96312d9cb5ad2a8244a0cb7722a49c4460
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282280
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-02-14 07:38:38 +00:00
Konstantin Shcheglov fc28153cc1 Use textual dumps for index.
Change-Id: I400d675a5c3a6c1c046583538873c0dec2f1e2e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282901
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-14 04:25:00 +00:00
Konstantin Shcheglov 6a6b54c7d3 Report unnecessaryWildcardPattern()
Change-Id: I6bca9eb8ec95796bdbcb02a017e919c424d8415d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282482
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-02-14 01:07:33 +00:00
Sam Rawlins bf6576470d [analyzer] Remove HintCode.PACKAGE_IMPORT_CONTAINS_DOT_DOT
We may move this to be a Lint (https://github.com/dart-lang/linter/issues/3939)
but for now there is no loss, as we never generate this diagnostic.

Bug: https://github.com/dart-lang/sdk/issues/50796 and
Change-Id: I4877884288a64722da4b5147f51cc3ecf934a76b
https://github.com/dart-lang/sdk/issues/48042
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282801
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-13 22:42:27 +00:00
Konstantin Shcheglov 2026b38fcc Report DEAD_CODE in logical-or pattern, when LHS always matches.
Change-Id: I54098d9bd611daf3b287fac8d35c2de8ffb40a09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282561
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-13 18:14:58 +00:00
Sam Rawlins 42402bf433 [analyzer] Move 6 more Hints to be Warnings, MISSING_*
Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Ie021ab23c4954c99ccb3f697302cada07b11cbf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282164
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-02-13 16:32:26 +00:00
Ahmed Ashour b33058488c [analyzer] UNNECESSARY_NULL_COMPARISON
to handle implicitly null assigned variables.

Fixes #51093

Change-Id: Iab04292656f16a1085d39bdcd9efa27b55a2ecbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279709
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-02-11 16:09:39 +00:00
Konstantin Shcheglov c6352b0e49 Unit tests for NON_EXHAUSTIVE_SWITCH and UNREACHABLE_SWITCH_CASE.
Change-Id: I0b291046eba881acd35aeba1f4725c84f0bc9bcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282160
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-10 21:50:27 +00:00
Konstantin Shcheglov 973e75ab35 Move 'matchedValueType' to DartPattern.
Change-Id: I1aa36197db8b5bb5742ea7f0724a962ec76118f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282393
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-02-10 21:41:11 +00:00
Konstantin Shcheglov a22fd3abfc Add a little more details for completion using OperationPerformanceImpl.
Specifically, we:

1. Extract separate 'body' operation in '_resolveForCompletion', so
  that we separate the timing of this method execution vs the timing
  how long it took to strat running this body.

2. Add `OperationPerformanceImpl performance` to `computeSuggestions`.

3. Remove 'DartCompletionManager-' prefix from completion operations.

Change-Id: I01986e06cb51167b7d5702a10f7512e04305298c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282387
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-10 19:35:49 +00:00
Sam Rawlins d7238f7401 Add WarningCode aliases for UNNECESSARY_TYPE_CHECK_*
These are (newly?) referenced in linter tests.

Bug: https://github.com/dart-lang/sdk/issues/50796
Change-Id: Icae6f9f4606fb331aacd85387f6beb2bbc2db2db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282165
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Samuel Rawlins <srawlins@google.com>
2023-02-10 18:23:08 +00:00
Konstantin Shcheglov f55f03ee20 Prune UriCache without using Finalizer.
Change-Id: Ibb07e24b2420da3c7553cd562c30a07b5ac899bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282161
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-02-10 17:09:03 +00:00