588 Commits

Author SHA1 Message Date
Konstantin Shcheglov 1309dffc0a CQ. Move analyzer diagnostics back into analyzer.
Move the analyzer-only Diagnostic, DiagnosticMessage, Severity, and
locatable diagnostic helper types out of _fe_analyzer_shared and into
package:analyzer.

I paln to make changes outlined in
https://github.com/dart-lang/sdk/issues/63311 and chat discussion.
Keeping these classes in the analyzer simplifies the migration and
avoids introducing a shared abstraction before there is a concrete need
for one.

If we decide later need to have a shared abstraction, we can always
extract one at that point. With coding agents internal code motion is
cheap.

Update analyzer, analysis server plugin, analyzer plugin, linter, and
scanner call sites to import the moved APIs from analyzer libraries, and
refresh API baselines to reflect the new public owner.

Change-Id: Ie0ef0f01c6e4be7ebaac25619ac3e3fe991a44d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501000
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-07 13:54:59 -07:00
Paul Berry 22013528d6 [messages] Use lower case diagnostic names in analyzer.
Changes the logic in `pkg/analyzer` to use
`DiagnosticCode.lowerCaseName` instead of `DiagnosticCode.name`, and
`DiagnosticCode.lowerCaseUniqueName` instead of
`DiagnosticCode.uniqueName`. This ensures that diagnostic codes are
matched in a case-insensitive fashion.

This paves the way for deprecating (and eventually removing) the
`DiagnosticCode.name` and `DiagnosticCode.uniqueName` getters.

Change-Id: I6a6a6964bae7f2d423e44211d2ad73202da65727
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/466281
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-12-09 08:04:44 -08:00
Sam Rawlins fae8a34f33 analyzer: Remove deprecated ErrorCode, ErrorSeverity, ErrorType
Change-Id: I914d0906ea417e186139c765b8d42a735dd263d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455461
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-10-19 20:41:36 -07:00
Paul Berry 4da74f6145 [messages] Move fastaAnalyzerErrorCodes to a new generated file.
This unties it from being associated with `ParserErrorCode`, which is
a necessary step toward allowing shared messages of types other than
`ParserErrorCode`.

Change-Id: I6a6a69643358904884cf22e5d2aaa455175e5c78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/454703
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-14 08:24:43 -07:00
Paul Berry 8b23e3449d [analyzer] Move some error reporting code into _fe_analyzer_shared.
The following classes are moved from `package:analyzer` to
`package:_fe_analyzer_shared`:

- `Diagnostic`
- `DiagnosticMessage`
- `DiagnosticMessageImpl`

The following declarations are also moved, since they are needed by
the above classes:

- `formatList`
- `Severity`
- `Source`
- `TimestampedData`

There is no change to the analyzer public API, and `export`
declarations have been added to the analyzer libraries that the
declarations have been moved from, so that code depending on these
declarations is unaffected.

These changes are part of a larger arc of work that introduces methods
`.withArguments` and `.at`, forming a literate API for reporting
analyzer errors that looks roughly like this:

    diagnosticReporter.reportError(
        ERROR_CODE.withArguments(...arguments...).at(...location...));

Moving this code into `_fe_analyzer_shared` is necessary because
scanner error codes are defined inside `_fe_analyzer_shared` (to allow
the scanner to be shared between the analyzer and CFE). Hence, to
avoid a circular depedency between `_fe_analyzer_shared` and
`analyzer`, the `.withArguments` and `.at` methods will need to live
in `_fe_analyzer_shared` too, as well as the classes representing the
diagnostic messages they create.

Note that there are some minor changes to
`pkg/analysis_server_plugin/api.txt` and
`pkg/analyzer_plugin/api.txt`; these have to do with the way the
`api.txt` generator chooses to report referenced elements, and don't
reflect actual API changes.

Change-Id: I6a6a6964a5c46f4a0205ce0d85620669ce55eb3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-08-12 11:09:33 -07:00
Sam Rawlins 97c49e7514 Deprecate errorCodeValues for diagnosticCodeValues
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ieea525a3f7260ea50e766feff0a0647fc0c33b4d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/434526
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2025-06-16 16:18:15 -07:00
Sam Rawlins 8a17ad9f05 analyzer: Deprecate AnalysisError in favor of Diagnostic
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: If9bbc96beed95129b099588c5bd9728afda8e392
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426902
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-05-08 14:02:16 -07:00
Sam Rawlins 49562fd152 analyzer: Deprecate ErrorCode in favor of replacement: DiagnosticCode
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I0cfc0bff4e5d10b7cb373f77de55fffc13b8cf76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426641
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-06 14:43:10 -07:00
Sam Rawlins 9ab2139df5 analyzer: Deprecate ErrorSeverity in favor of DiagnosticSeverity
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Ic7f84584d4185e1ab7e8741052ec6694487c8c08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426600
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-05 13:58:32 -07:00
Sam Rawlins 57bfb6abd6 analyzer: Use new DiagnosticCode name in some directories
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: I942e690ab2946c564c10df228d17bd44de4ed375
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425406
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-02 11:02:20 -07:00
Sam Rawlins 23b3450c8e analyzer: Make AnalysisError an alias for Diagnostic
Work towards https://github.com/dart-lang/sdk/issues/60635

Diagnostic has exactly one direct subclass, AnalysisError
(AnalysisError has a few more for tests). Diagnostic was previously
referenced only 7 times in all of analyzer.

This change is essentially a no-op.

Change-Id: I043970d96adcd7be4bb6a24d4a85b3f74309b7d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425682
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-05-01 10:08:05 -07:00
Sam Rawlins 35e8b9ba0b analyzer: Deprecate ErrorType in favor of new name, DiagnosticType
Change-Id: I552e816de6d526e3476cac9dd3ee2919fc7ec499
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425720
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2025-04-30 19:07:42 -07:00
Sam Rawlins 992cfb13bc analyzer: Deprecate AnalysisError.correction; simplify other final fields
Work towards https://github.com/dart-lang/sdk/issues/60635

* `AnalysisError._contextMessages` unnecessarily backed the public
  `contextMessages` getter; the field is final so it can be public
  itself.
* `AnalysisError._correctionMessage` unnecessarily backed the public
  `correctionMessage` getter; the field is final so it can be public
  itself.

Change-Id: If269d4ed590ef7df81d9b9e3be03766601526d7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425620
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-30 16:06:19 -07:00
Sam Rawlins cd07d191fc analyzer: Make AnalysisError._problemMessage non-late and public
Work towards https://github.com/dart-lang/sdk/issues/60635

Change-Id: Id80912299c8bd9caafb9f6a9521168c74911f90d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425581
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-30 09:44:18 -07:00
Sam Rawlins d1696f890d CFE: Introduce type aliases for ErrorCode, ErrorSeverity, ErrorType
Work towards https://github.com/dart-lang/sdk/issues/60635

In this CL I only introduce the typedefs, update comments, and export
the typedefs. I don't change any references. Next we should update
internal references and maybe separately, any generated references.

Change-Id: I1c6d16580533b9283934261f56a6e5237e59109e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425343
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2025-04-29 16:19:30 -07:00
Konstantin Shcheglov becd91df17 Format analyzer/ with tall mode.
Change-Id: I410cd1cf63fbf00b868bbb3e060433cad3ac9e6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423520
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-04-21 12:15:58 -07:00
Konstantin Shcheglov cf1f2e53a3 Breaking changes for analyzer version 7.0.0
Change-Id: Id6e329c7665d1dca1920d744dd7d0e9722da768c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311461
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-10-21 21:32:28 +00:00
Sam Rawlins 0e39ed67e6 analyzer: Expose LintCode as public API, for plugins
Work towards https://github.com/dart-lang/sdk/issues/50986

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try,analyzer-win-release-try,pkg-win-release-try
Change-Id: Ie5783240e3fc2c9f8076b3efb13f79a3b8fa5000
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/375060
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2024-07-09 22:16:00 +00:00
Konstantin Shcheglov b4e30d1b45 CQ. Deprecate unused static members of AnalysisError.
Change-Id: I46e76defbc9a833a867cc3fa2154635f71a6d085
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371422
Reviewed-by: Sam Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-06-13 23:39:21 +00:00
Konstantin Shcheglov 4f6cca1e1e CQ. Extract package:analyzer/error/error.dart library cycle.
By removing unnecessary references to higher level libraries we
can extract a separate 19 libraries cycle, related to errors. Maybe
later we can break it further.

This reduces the mono-cycle from 295 to 270 libraries.

Change-Id: Id9db12002dba10788b65262d3d7325ad6079ceff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-05-31 20:22:28 +00:00
Sam Rawlins 73ab31b98a analyzer: Move the Source class to be public API.
Deprecate accessing LineInfo, Source, or SourceRange via the
old library (pkg/analyzer/lib/src/generated/source.dart).
Migrate all SDK code to the new library.

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

Change-Id: Ic7c98a5820415c92a457f9fa2756351b05520cd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-11-14 17:10:37 +00:00
Konstantin Shcheglov 4f7295ad26 Record elements and types parts of missing patterns for AddMissingSwitchCases fix.
Bug: https://github.com/dart-lang/sdk/issues/51985
Change-Id: I48e04e992ccab5cb5dedb5df328ba13ffcf6b560
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302200
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-09 16:29:20 +00:00
Konstantin Shcheglov 036b8cafad Add AnalysisError.tmp() constructor, deprecate the default one.
Bug: https://github.com/dart-lang/sdk/issues/51985
Change-Id: I1204c71a4c5ea62d32d65662ecb5274dacb0bfae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301730
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 14:39:29 +00:00
Ahmed Ashour 0b5d908221 [analyzer] NOT_ENOUGH_POSITIONAL_ARGUMENTS
To report at the token of the expected positional argument

Fixes #50127

Change-Id: I5eb31c6d354fb15d482c2046f7faaa4505658f4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262603
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-10-11 17:56:11 +00:00
Brian Wilkerson 38581783e6 Generate the list of error codes
Change-Id: I315619a30ac8690e90be2b3a3ad7d849c28f2c05
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263441
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-10-10 17:26:00 +00:00
Konstantin Shcheglov 8d1297628a More tests for ExtractorPattern resolution, report errors.
Change-Id: I800f909a1d58e8bebcbfa30e52f09a16906b1e07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263142
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-10-07 18:35:35 +00:00
Konstantin Shcheglov 5ef329cf74 Report CompileTimeErrorCode.DUPLICATE_VARIABLE_PATTERN
Change-Id: I07cb697c9c517f0d4eb67100f0ae134aa821d25d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263002
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-10-07 00:16:27 +00:00
Konstantin Shcheglov 57a619bcb7 Report diagnostics for relational patterns.
Change-Id: I1a3e02e36679599e0240f74108a5e91db6269b1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262900
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-10-06 16:33:41 +00:00
Jens Johansen e860cf241b [parser] Empty record
https://github.com/dart-lang/language/pull/2535

Change-Id: I8241119ee858ce39673472056b88c9393799e1a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262600
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-06 06:34:58 +00:00
Sam Rawlins 15be61ed9a Remove INVALID_OVERRIDE_DIFFERENT_DEFAULT_VALUES warnings
Fixes https://github.com/dart-lang/sdk/issues/49112

It was decided to remove the "override with equal default value"
restriction both for null safe code, and for pre-null safe code.

CFE had never issued this static warning, and her we remove it from
analyzer.

Change-Id: I1244e4fe46da8bb4bd8c3a77ec8beb95811e30a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262267
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-10-04 18:23:10 +00:00
Ahmed Ashour 6da33ae60f [analyzer] add HintCode.DUPLICATE_EXPORT
Fixes #49439

Change-Id: I511205c6b0960f6b19a2ac45211bc1348568f52c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260703
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-10-03 23:22:18 +00:00
Konstantin Shcheglov c73228abaf Report an error when a variable pattern binds in one branch of logical-or, but not in another.
Only check for if-case is implements for now.

Change-Id: I57d1b8b33fbe2bf7adc848b5d607ff99b878b479
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262101
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-09-30 18:53:26 +00:00
Konstantin Shcheglov 1aa398d4be Report EXPECTED_NAMED_TYPE_X when not a NamedType is parsed.
Change-Id: Ibebc276777075da12e36642f08291fa9a9f9ac91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260073
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-09-21 02:24:45 +00:00
Ahmed Ashour 63f69b4756 [analysis_server] add a quick fix for some AnalysisOptionsHintCode
Fixes #49513

Change-Id: Ib4a1b68c95c2f379e8cbdaf62b2b17bf0a25e7b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252580
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-09-06 18:26:46 +00:00
Ahmed Ashour 17e0f87252 [analyser] add MISSING_DEFAULT_VALUE_FOR_PARAMETER_POSITIONAL
Fixes #49816

Change-Id: I48f3c21fcf552e21da70cf12adf3671c3f490695
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256840
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-30 20:55:38 +00:00
Jens Johansen cec94a1446 [parser] Empty record types, record types with 1 element
This should bring parsing of record types up-to-date with v1.6 of
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Also fixes https://github.com/dart-lang/sdk/issues/49826

Change-Id: I3737a72ddee49a957bd55f86cc200fb77f23e2a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-08-30 11:04:10 +00:00
Jens Johansen a4352d09e1 [parser] Record literals can be const and one-element only
This should bring parsing of record literals up-to-date with v1.6 of
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Change-Id: If39bb1834137da55ef8bd1923106bbc614ea319b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256461
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-08-30 10:54:08 +00:00
Brian Wilkerson 9d1a877082 Generate diagnostics for invalid field names in record literals
Change-Id: I12ece78e257b1265d86114e8c17e6a8c641559e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256364
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-08-25 17:47:06 +00:00
Brian Wilkerson 2b27d3257b Report duplicated field names in record literals
Change-Id: Ifc5c3a06c7f489b00421f5b1af47df52615694d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256200
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-08-24 16:33:49 +00:00
Sam Rawlins 4fcbbb107a Add CAST_FROM_NULL_ALWAYS_FAILS check
Fixes https://github.com/dart-lang/linter/issues/3605

Change-Id: I5f9a2b127173aa9f2cc6f8fcee9c93e96cb63663
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255149
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-08-16 23:41:02 +00:00
Sam Rawlins 7280525117 Implement mustBeOverridden annotation and enforcement
Fixes https://github.com/dart-lang/sdk/issues/30175
Fixes https://github.com/dart-lang/sdk/issues/28250

Change-Id: Id9c62448da9ade81258c2ae2355d05117057a8f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252463
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-07-25 22:17:18 +00:00
Konstantin Shcheglov 21d0028643 Resolve augmentation import directives in libraries.
Change-Id: I900d262df4b32698e20907a3bb99e88fbee38d3e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/252006
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2022-07-20 17:08:58 +00:00
Jens Johansen 25dcfca3c2 [parser][CFE][analyzer] Function is builtIn keyword
This CL makes `Function` a builtIn keyword instead of a `pseudo` keyword.

See also (and fixes):
https://github.com/dart-lang/sdk/issues/45703
https://github.com/dart-lang/sdk/issues/45704
https://github.com/dart-lang/sdk/issues/45705
https://github.com/dart-lang/sdk/issues/49197

This undoes https://dart-review.googlesource.com/c/sdk/+/195761

This is ~a merge of https://dart-review.googlesource.com/c/sdk/+/195906
and https://dart-review.googlesource.com/c/sdk/+/200080

Change-Id: I8bfee6976d43819fa355de99b3b2429eb67a7cdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249484
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-06-28 14:26:33 +00:00
Konstantin Shcheglov e78399ac52 Issue 23067. Report HintCode.DEPRECATED_EXPORT_USE
It found a few cases for `BytesBuilder` exported from `dart:io`.
I fixed most of them in a separate CL.

But package:flutter (itself only) is clean.

There are a few violations in google3.
I will ignore most of them, and fix a few.

Bug: https://github.com/dart-lang/sdk/issues/23067
Change-Id: Ic89370ad84caa60fd49326c2bc60ad5d927e2264
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248343
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2022-06-18 18:17:40 +00:00
Daco Harkes a855030120 [vm/ffi] Allow struct nesting with looser packing
C compilers don't enforce nesting rules. `dart:ffi` was enforcing these
rules causing issues for binding to C libraries having looser packing
for nested structs than outer structs.

This CL completely removes the error from the analyzer and CFE.
(As an alternative we could have kept a hint/lint, but this might create
more noise than value.)

TEST=pkg/analyzer/test/src/diagnostics/packed_nesting_non_packed_test.dart

Closes: https://github.com/dart-lang/sdk/issues/46644
Change-Id: Iae2d5c885546f7799bc6dea2f8cd7dd508216a0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247382
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-06-09 19:08:43 +00:00
Konstantin Shcheglov 73935c1d83 Report MACRO_EXECUTION_EXCEPTION.
Change-Id: Ia4c9b897467ce276c2030cbf242146aa95410189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241988
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-04-22 01:10:28 +00:00
Ahmed Ashour f2b5ba82ab Add a hint for final FieldFormalParameter and SuperFormalParameter
Fixes #48699

Change-Id: Ieb16648a52884588e406931f830e4655b120cb0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239640
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-04-10 18:11:00 +00:00
Daco Harkes 532c116cd2 [vm] Implement NativeFinalizer
This CL implements `NativeFinalizer` in the GC.

`FinalizerEntry`s are extended to track `external_size` and in which
`Heap::Space` the finalizable value is.

On attaching a native finalizer, the external size is added to the
relevant heap. When the finalizable value is promoted from new to old
space, the external size is promoted as well. And when a native
finalizer is run or is detached, the external size is removed from the
relevant heap again.

In contrast to Dart `Finalizer`s, `NativeFinalizer`s are run on isolate
shutdown.

When the `NativeFinalizer`s themselves are collected, the finalizers are
not run. Users should stick the native finalizer in a global variable to
ensure finalization. We will revisit this design when we add send and
exit support, because there is a design space to explore what to do in
that case. This current solution promises the least to users.

In this implementation native finalizers have a Dart entry to clean up
the entries from the `all_entries` field of the finalizer. We should
consider using another data structure that avoids the need for this Dart
entry. See the TODO left in the code.

Bug: https://github.com/dart-lang/sdk/issues/47777

TEST=runtime/tests/vm/dart(_2)/isolates/fast_object_copy_test.dart
TEST=runtime/vm/object_test.cc
TEST=tests/ffi(_2)/vmspecific_native_finalizer_*

Change-Id: I8f594c80c3c344ad83e1f2de10de028eb8456121
Cq-Include-Trybots: luci.dart.try:vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-ffi-android-debug-arm64c-try,dart-sdk-mac-arm64-try,vm-kernel-mac-release-arm64-try,pkg-mac-release-arm64-try,vm-kernel-precomp-nnbd-mac-release-arm64-try,vm-kernel-win-debug-x64c-try,vm-kernel-win-debug-x64-try,vm-kernel-precomp-win-debug-x64c-try,vm-kernel-nnbd-win-release-ia32-try,vm-ffi-android-debug-arm-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-mac-debug-x64-try,vm-kernel-nnbd-mac-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,benchmark-linux-try,flutter-frontend-try,pkg-linux-debug-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-gcc-linux-try,vm-kernel-optcounter-threshold-linux-release-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-x64c-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236320
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2022-03-26 09:41:21 +00:00
Sam Rawlins d5cc53a1b8 Prefer for-loop over forEach; other little fixes
These linter fixes help prepare analyzer for lints 2.0.0

Change-Id: Ic942fa367965edac479b917cbbb601b30da8b53c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237766
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-03-18 03:37:47 +00:00
Jens Johansen fd4e41a7af [parser-ish] Better errors on invalid unicode escapes
https://github.com/dart-lang/sdk/issues/48542

Change-Id: Icbdcc939a93c737914091c00aaefa3c4efb2dde0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/237364
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-17 13:57:45 +00:00