- copy sanitizer runtime when using ubsan;
- avoid use of winnt.h CONTAINING_RECORD since it triggers ubsan "member access within null-pointer of type" error, use our copy which uses `offsetof`;
- have default virtual destructor in `ValueObject` to avoid ubsan complains about "insufficient space for an object of type 'dart:ValueObject'" at NoTemporaryAllocator use/declaration site;
- have virtual destructor in ZoneAllocated to avoid ubsan complains about "not having enough space to allocate object" at new RegExpEmpty() instantiation site;
- avoid using crashpad with ubsan as it causes dartvm to exit with error code 3;
- switch to windows, mac-friendly `[[gnu::no_sanitize(check)]]` from `__GNUC__` and `__has_feature` checks.
TEST=ci
Bug: https://github.com/dart-lang/sdk/issues/62267
Change-Id: I8b922a8da329af276d4cefaa88fb841cc0457124
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469840
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
Converts the analyzer's logic for reporting the following errors to
use the new literate diagnostic reporting API:
- expectedOneListTypeArguments
- expectedOneSetTypeArguments
- expectedTwoMapTypeArguments
Change-Id: I6a6a6964a1a020eee27d0636ddb39c7f71619fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471302
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Changes the diagnostic reporting logic for the following diagnostic
codes to use the analyzer's literate diagnostic reporting API:
- invalidImplementationOverride
- invalidImplementationOverrideSetter
- invalidOverride
- invalidOverrideSetter
Change-Id: I6a6a696433e729c1122995d9ac2a183c7cdbfa04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471300
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
With these changes, primary constructor bodies will sort with
constructors (based on whether `sort_members_first` is enabled), but
will always be before other constructors.
Change-Id: If6719dedd5178c384712a5d08b4e74a38aaf54a1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471280
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
When mixin is applied, its instance members are cloned and copies
of the members would override original members.
This change fixes bugs and improved usability of extendable mixins with
private members:
- All instance members of extendable mixins and mixin classes are
marked as can-be-overridden to allow overriding by cloned members
when mixin is applied.
- TFA no longer takes privacy into account, as private members of
mixins can be overridden by their clones in other libraries.
- Dynamic module validator always unwraps cloned members to originals
before verifying if overriding is allowed. This eliminates overriding
errors between clone(s) and original members of mixins.
TEST=pkg/dynamic_modules/test/data/mixin_private_member1,
pkg/dynamic_modules/test/data/mixin_private_member2
Fixes b/470461203
Fixes b/469094721
Change-Id: If369c42c58e5ea4d707be83b1e7078ee9a8cc3ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470803
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
* `_getAnalysisOptions` did not use it's first parameter, so remove it.
* `_getAnalysisOptions` is only ever passed a non-nullable
`optionsFile`, so make it non-nullable.
* `DriverBasedAnalysisContext.allAnalysisOptions` are
AnalysisOptionsImpl objects, so leave them alone and prevent later
casting.
Change-Id: Ida490f6a9eeba16c14727e48a306ea336a7ce8a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470500
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Pausing read on the SecureSocket should pause read on the underlying
socket, because otherwise we will be stuck calling _readHandler
which will not read anything but still schedule an SSL filter
wasting CPU time.
Fixes https://github.com/dart-lang/sdk/issues/62037
CoreLibraryReviewExempt: No API changes, VM specific implementation change
Change-Id: I4144815d34c1e77a68533b6ebcb66c146a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/467804
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Refactoring:
- Update the checks when updating a local for a captured variable to
check whether `local` is null, instead of whether it's not updated.
If the `local` is available then we know that it's not updated. It's
more direct to check whether we've created a local for the variable or
not.
- Add an assertion checking the the capture field and local for a
variable can only differ in nullability.
Documentation:
- Document that context field for a captured local will always be
nullable, to be able to allocate the context without dummy values.
- Document in a few places that `!capture.written` means the variable is
captured but not updated, so they can be held in a local (instead of
getting them from the context on every read).
Change-Id: I66048cb36f75e35ee3c479c41f2bbfca247a990f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470981
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
- Remove redundant `prepareDummyValue` call in
`getGlobalForStaticField`.
- With the previous change, `prepareDummyValue` can be made private.
Make it private and rename it to `parepareDummyValueGlobal` to make it
clear that it creates a global.
- Make `prepareDummyValueGlobal` return early when the type doesn't need
a dummy value global. With the early return the function body is
de-indented one level.
- Document `DummyValueCollector.dummyStructGlobal`.
Change-Id: I6dd93ca5fb25898c1b05dda03573905e76450923
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471220
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
We bumped NTDDI_VERSION to Windows 10 but have not updated WINVER in
the same way making them diverge for no good reason.
FWIW NTDDI_VERSION should probably be set by winver config, but I am
not going to fix that now.
Change-Id: I53cdf1cde40aa50911aa1311ca15705d6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471181
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
https://dart-review.googlesource.com/c/sdk/+/469240 (originally landed
as https://dart-review.googlesource.com/c/sdk/+/465760) introduced a
leak by saving assessors on dill libraries. Note that we _do_ save
assessors on source libraries, but as these are converted to dill
libraries (via the incremental compiler, i.e. in the setting where the
leak happens) this is fine, but saving them on dill libraries means that
these will retain access to old/invalidated/recompiled libraries and
thus leak. The weekly bot has been red since the run on 2025-12-21.
This CL fixes the issue by reporting the wanted errors when processing
the import instead of later and can thus stop saving the data that
causes the leak. It also moves when it's done so the error is issued for
outline compiles too.
Change-Id: I88385ef193edfe45cd56b5e42a442c0e2bda7608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471200
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
This refactors building of initializers to be fully contained within the [_InitializerBuilder].
This prepares for handling primary constructor body declarations which require a change to how building of constructor initializers are triggered. Currently it is assumed the initializers can be processed with the constructor declaration has been parsed, but with primary constructor body declarations, such processing needs to be postponed. Streamlining the logic for processing the initializers makes it easier to accommodate this.
Change-Id: Ic12e208bce5d1ed9b3800335466afcaf391c1b9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471000
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This issue was partially fixed by:
https://dart-review.googlesource.com/c/sdk/+/428541
However, this only looked at the case of a member in an abstract class
that itself was made abstract if it was unused. TFA does not make the
member abstract if the enclosing class is not abstract:
pkg/vm/lib/transformations/type_flow/transformer.dart#L2289
Instead we can use the unreachable metadata to identify these
unreachable body members (that have default values cleared):
pkg/vm/lib/transformations/type_flow/transformer.dart#L736
Attached test fails prior to this fix.
Bug: https://github.com/dart-lang/sdk/issues/62273
Change-Id: I1ccb818ec41bbe805ee828be0b96ba23e73beae4
Tested: Introduced unit test.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469280
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Converts the analyzer logic that reports the following messages to use
the literate diagnostic reporting API:
- duplicatePart
- invalidUri
- partOfDifferentLibrary
- partOfNonPart
- partOfUnnamedLibrary
- uriDoesNotExist
- uriHasNotBeenGenerated
- uriDoesNotExistInDocImport
Change-Id: I6a6a6964a121855a4a0407b829195f6c60d049fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471024
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Changes the analyzer logic that reports the following messages to use
the literate diagnostic reporting API:
- duplicateDefinition
- duplicateFieldFormalParameter
- duplicateFieldName
- duplicateVariablePattern
- prefixCollidesWithTopLevelMember
- privateNamedParameterDuplicatePublicName
Also, makes the parameter lists for all these messages uniform: every
one of these messages now accepts a single String parameter named
`name`.
Change-Id: I6a6a696426d6176eb3ff2401e3b4d68bed823323
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471023
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
- Skip notifications from analyzer
- Hard code responses to certain startup logs if they are unexpected
- Use cli_util to show loading spinner and get sdk location
- Update normalize to substitute the sdk location
- Make id field optional on message (notifications don't have ids)
Change-Id: Ia5276eef554a3afefeae227fa7351f902d21131e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471060
Auto-Submit: Jake Macdonald <jakemac@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Adds type parameter names to the diagnostic messages
`constWithNonType` and `newWithNonType` (both of which are reported to
the user as `creation_with_non_type`), and adjusts the code that
reports these diagnostic messages to use the new literate diagnostic
reporting API.
Change-Id: I6a6a696470bbc684950e65ccb0e5a780e79ea463
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471021
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This simplifies reporting logic by avoiding "already reported by the
parser" case. Also, in a follow up CL I plan to support declaring formal
parameters, which do not look as `this._foo` syntax. Supporting this in
the parser would require duplicating more complex logic of building
elements in the analyzer.
Another way to think about it, is that from parser point of view the
code is fine - we did not skip or add any tokens. We can parse and
format this code. But the semantics is not quite right, so it makes
sense to put it in a different place.
Change-Id: I783ed6780e6d66e276c5ed44f08e6ac04145cd1f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470920
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This diagnostic is reported in two circumstances:
- During resolution of a dot shorthand like `const .foo()`, when the
implicitly-referred to class doesn't have a constructor with the
given name.
- During resolution of a const constructor invocation like `const
int.foo()`, when the explicitly-referred to class (`int` in this
example) doesn't have a constructor with the given name.
In both cases, the diagnostic message includes the names of both the
class and the constructor that was sought. But in the first case, the
class name was accidentally derived from the type inference context
rather than the dot shorthand context; these are different in the case
where the dot shorthand appears on the RHS of `==`. Fixed by supplying
the correct context type.
This bug was discovered in the process of converting the analyzer to
use the new literate error reporting mechanism: I needed to assign a
type to the diagnostic message parameter that was to contain the class
name and discovered that I couldn't give a consistent type, because it
was sometimes being filled in with a class name string, and it was
sometimes being filled in with a type. With the fix, it is always
filled in with a class name string.
I also included tests of the other dot shorthand related diagnostics
that mention the class name (they don't exhibit the same bug), as well
as a typo fix for `wrongNumberOfTypeArgumentsDotShorthandConstructor`
(which had mismatched quote symbols).
Fixes https://github.com/dart-lang/sdk/issues/62352.
Change-Id: I6a6a696421b68397b86aac9b1a6e91cce08250ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470942
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
The only changes in this CL that were manually written are those in
`messages.yaml`. The others were produced by running the standard
diagnostic message code generator and then running the script
`use_literate_api_in_analyzer.dart`.
Change-Id: I6a6a69645bab7cf8f26ec9524a7bc2294e4a3b3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/471020
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
When creating an instance of a class or calling a factory constructor,
dynamic module may pass a vector of instantator type arguments which
includes types mentioned in supertypes along with types specified
at the call site.
So, for every exposed generative constructor and factory all the types
mentioned in the supertypes of their declaring classes should be
annotated as implicitly callable in order to prevent their tree-shaking.
TEST=pkg/dynamic_modules/test/data/super_type_param
Fixes b/470446652
Change-Id: I6abe570261a8f23f8022cb77110c3a5ec40ccbe8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470781
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Changes the uses of `DiagnosticReporter.atElement2` in
`evaluation.dart`, `base_or_final_type_verifier.dart`, and
`getter_setter_types_verifier.dart` to use the new literate diagnostic
reporting mechanism.
Change-Id: I6a6a6964cff8afd9867c2606f3aea334f135cf03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470820
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
This adds the sealed class Argument with subclasses PositionalArgument and NamedArgument to the internal AST and uses these through out compilation. This cleans up a lot of the handling of arguments during inference.
Change-Id: If604895ee578d45874d4760e5ead2426b19b96ff
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469621
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
This [handlePositionalArgument] and [handlePositionalRecordField] methods to the parser listener, allowing listeners to normals arguments and record fields
Change-Id: I3947e196dafffea2ab383f797904c857db8327ce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/469620
Reviewed-by: Jens Johansen <jensj@google.com>
- Remove unused `masquerade` member.
- Make `upperBound` private.
- Fix spelling of `Dart` and `Wasm` in comments.
Also use `ClassInfo.typeWithNullability` in one more place in
`translator.dart`.
Change-Id: I08ef9a0599c9c3ecbe2b8d9e4a1d63124695813b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470662
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
This data is collected on shutdown, the same as the legacy analytics data.
This is implementation for some of the analytics we want to collect,
specified at go/dart-analyzer-plugin-analytics.
* How many plugins are enabled for each context?
* How many lint rules are registered for each plugin?
* How many warning rules are registered for each plugin?
* How many fixes are registered for each plugin?
* How many assists are registered for each plugin?
Change-Id: I36c176737c194550e1947985576ed461fd8a1bf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452482
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
The advantage of using `firstFragmentLocation` rather than
`firstFragment` is that `firstFragmentLocation` doesn't disable
fine-grained dependencies.
Change-Id: I6a6a696482ffef9fabc2688a14ea417b592c65fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470801
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>