Commit Graph

56222 Commits

Author SHA1 Message Date
Konstantin Shcheglov 245105300c CQ. Migrate diagnostics tests to resolveTestCodeWithDiagnostics. A-B.
Change-Id: I260150562d253f480f70f04b7038fc7bcdadca26
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501764
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 13:16:41 -07:00
Nate Biggs 63d042fe0d [dart2wasm] Fix dynamic dispatch table population for multiple modules.
When deferred loading was enabled the dynamic dispatch class ID table
was incorrectly assigning class IDs to the wrong module. If a contiguous
target segment included classes/targets from different modules, all of
them were getting assigned to the module of the first class/target in
that segment.

This was causing spurious NSM exceptions as the necessary rows in the
table might not be populated for a dynamic call if the module the
segment was assigned to wasn't loaded yet.

To fix this we end the segment if the next target does not belong to the
same module as the active segment.

The new test fails with an NSM exception prior to this fix.

Change-Id: I07bc4fdb5a8bff1bfad5fe17f45c8076a965a775
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502860
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-12 12:54:38 -07:00
Helin Shiah 405b6c5614 Send IDE and plugin info to analytics
Bug: https://github.com/dart-lang/sdk/issues/62996
Change-Id: Id2bd122acf4a40a01a7dc760e44f164b04f204ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497123
Commit-Queue: Helin Shiah <helinx@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-05-12 12:39:44 -07:00
Danny Tuppeny 26c646642d [analysis_server] Add kinds to LSP document highlights
Populates the `kind` on the Document Highlights we return. This allows colouring reads and writes differently (which it turns out VS Code does by default).

The options are a bit limited (Read/Write/Text) and using Read/Write for things like type names feels slightly odd, but the spec does seem to encourage this and it's what TypeScript is doing.

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

Change-Id: I6a53450038cde31b399b5b1aca5f964083106763
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503060
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
2026-05-12 12:04:29 -07:00
Konstantin Shcheglov cddfbfb7e3 BL-co19. Don't report nonFinalFieldInEnum for external fields.
External fields don't have storage.

Now pass:
co19/LanguageFeatures/Enhanced-Enum/grammar_A07_t01

Change-Id: Ia4dd616dd211be6c05b93f174785cb2b30644a72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502420
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 11:57:29 -07:00
Brian Wilkerson 2b1ed6614e Add a fix for use_declaring_parameters
This is another step toward being able to maximally convert a body of
code to using the primary_constructors features.

This CL does two things:

- Changes `convert_to_declaring_parameter` to also be a fix and applies
  that fix to the `use_declaring_parameters` lint.

- Updated the `use_declaring_parameters` lint to also flag field formal
  parameters.

Change-Id: I8b584186658abc73c025b166c145efbab95acd8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502740
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-12 11:56:25 -07:00
Kallen Tu 509caefa07 [migrate] Update error message when failing to parse pubspec.
Danny mentioned that the error message is missing the file name because
we're using the directory path. Updated the message and added a small
test.
https://dart-review.googlesource.com/c/sdk/+/496801/comment/d1e2d8cf_83c52831/

Bug: https://github.com/dart-lang/sdk/issues/63247
Change-Id: I6bc7cbd18a70328cd0c549672459944c220b177a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2026-05-12 11:49:26 -07:00
Konstantin Shcheglov 9c89bc5f87 BL-co19. Mixin application classes stay const if mixin does not have instance fields.
Now pass:
co19/Language/Mixins/Mixin_Application/implicit_constructor_A01_t05
co19/Language/Mixins/Mixin_Application/implicit_constructor_A02_t03
co19/Language/Mixins/Mixin_Application/implicit_constructor_A03_t06
co19/Language/Mixins/Mixin_Application/implicit_constructor_A03_t07
co19/LanguageFeatures/Static-access-shorthand/equality_A02_t06

Change-Id: I804ceaae6f6751d61fdb7f82be17938c0e5c88c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502380
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 11:48:21 -07:00
Paul Berry 836ae16c9b [analysis_server] Expand on doc comment for BulkFixProcessorTest.
Recording Brian's answer to my code review question
(https://dart-review.googlesource.com/c/sdk/+/502740/comment/72581051_c4bd020e/)
for posterity.

Change-Id: I25a06504c80b0189ba11b35a7bc713aa6a6a6964
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/503100
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-12 11:39:23 -07:00
Konstantin Shcheglov 0bfdcca1e0 BL-co19. Report classUsedAsMixin for 'with Enum' even with class modifiers feature.
The logic for reporting errors on type hierarchies is... tangled.

Now pass:
co19/LanguageFeatures/Enhanced-Enum/implementing_enum_A05_t01

Change-Id: I7aedf140ad2556532fb8d4a1d006aba7c051c591
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502460
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-12 11:15:51 -07:00
Brian Wilkerson 2fa07c6488 Lint fields initialized in the initializer list instead of the field initializer
This CL adds a lint as part of the collection of lints used to automate
converting code to use the features under the primary constructors flag.
The lint flags initializers in a primary constructor body that
initialize a field in such a way that the initialization could be done
in the field declaration's initializer.

It only flags assignments to fields where the right-hand side of the
assignment includes a reference to one or more of the constructor's
parameters. Expressions that don't reference a parameter would have
been valid to move before primary constructors, so flagging them
wouldn't help find bugs in the impementation of the feature.

If we were going to ship this lint, then we might want to extend it to
find initializers that don't reference parameters, whether they are in
the primary constructor body's initializer list or in the initializer
list of a secondary constructor.

This doesn't include a fix. Once again, I wanted to make sure the lint
was covering all the important cases before implementing the lint.

Change-Id: Id4b1e02ec160af50af8f4fe7b8c675213e41abc7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502202
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-12 10:47:20 -07:00
kevmoo 58e1cbe1a7 api_summary: add basic CLI and validation test
Change-Id: I3e9b5a4c3f1d31967a503c4caf273b9d8f239095
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502840
Auto-Submit: Kevin Moore <kevmoo@google.com>
Commit-Queue: Kevin Moore <kevmoo@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-12 10:44:46 -07:00
Ryan Macnak 06bfb29baa Make tools/test.py --build work with sanitizers.
Change-Id: I4680b4f3feb7eb29a7bd219118286173f50c5726
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501280
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-05-12 09:23:35 -07:00
Nate Biggs c2a1b4452d [dart2wasm] Handle directory creation better when emitting compiler outputs.
Add checks to create enclosing directory before writing any files. If
the directory does not exist, these file creations will end up in an IO
exception.

Since dart2wasm might be writing many files to the same directory, keep
track of directories we know exist in memory to skip the extra file I/O.

Change-Id: If2d4a4973fe58f12c26d98578418420d964c3f84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502600
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-05-12 08:18:06 -07:00
Tess Strickland 1fb0c0c231 [vm,dynamic_modules] Add record-coverage bytecode option.
This CL only adds the option and appropriate uses of it. Followup
CLs will use it to actually generate appropriate instructions and
metadata for collecting coverage information.

TEST=ci (just adding flag)

Cq-Include-Trybots: luci.dart.try:vm-dyn-linux-debug-x64-try,vm-aot-dyn-linux-debug-x64-try,vm-aot-dyn-linux-product-x64-try
Change-Id: I194154ef926abe7dae8bb93f397fb68029e2db3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501500
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2026-05-12 07:46:06 -07:00
Konstantin Shcheglov eae9edeb2e Augment. Fix pre-existing cases when already complete declaration is augmented with a complete declaration.
Change-Id: Ie2ff45ec5801dee2bfbc115719ba1a6f85f8cbe3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502187
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 07:42:33 -07:00
Konstantin Shcheglov fe2fc3780a AD. Fix index printing in tests when running on Windows.
Change-Id: Ibd58b4ec41297baad2356dc90858c92c154dd29a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502741
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-12 07:28:07 -07:00
Konstantin Shcheglov acb6714ac1 BL-co19. Report useOfVoidResult for forIn and null-aware uses in collections.
Now pass:
co19/Language/Types/Type_Void/implicit_usage_A01_t01
co19/Language/Types/Type_Void/implicit_usage_A02_t01
co19/Language/Types/Type_Void/permitted_use_A15_t02
co19/Language/Types/Type_Void/permitted_use_A15_t04

Change-Id: Icb641ee97ea358eaa2dc9f1545ad05281d2b614e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502400
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 07:20:21 -07:00
Konstantin Shcheglov e7051906d2 BL-co19. Report inconsistentInheritanceGetterAndMethod on a corresponding declared member, if exists.
Now pass:
co19/Language/Interfaces/Superinterfaces/Correct_Member_Overrides/correct_member_overrides_A01_t02
co19/Language/Interfaces/Superinterfaces/Correct_Member_Overrides/correct_member_overrides_A01_t04

Change-Id: Ib0de590fb3b405d0e07b1b03b9e6f351cdd67870
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 07:20:01 -07:00
Konstantin Shcheglov 00332504d9 BL-co19. Use unionFreeType to compute element type of generator functions.
See https://github.com/dart-lang/language/pull/3218

Now pass:
co19/Language/Functions/element_type_A01_t01
co19/Language/Functions/element_type_A01_t02
co19/Language/Functions/element_type_A02_t01
co19/Language/Functions/element_type_A02_t02

Change-Id: I6a55246b33868027ff0114c8c6a17910524a8fed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502341
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 07:12:18 -07:00
Konstantin Shcheglov 0454f270b0 BL-co19. Report invocationOfNonFunctionExpression when invoking record typed variable with named field 'call'.
Now pass:
co19/Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A02_t02
co19/Language/Expressions/Function_Invocation/Function_Expression_Invocation/call_A04_t03

Change-Id: I4a929ebb6ce5c523b78bf6a2e8b98e0a5981a0e5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502340
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-12 07:11:53 -07:00
Alexander Markov 6195ea86bc [vm] Remove irregular type arguments parameter from factories
In the VM, factory constructors always had an extra "type arguments"
parameter, even if class is not generic. Factory constructor bodies
were using class type parameters instead of function type parameters.

This results in extra code when calling non-generic factories
which is slightly inefficient in terms of code size and performance.
Also, it creates an additional complexity throughout the system as
factories should be special cased in many places.

This change removes artificial "type arguments" parameter, treating
factory constructors basically as static methods. This matches
kernel AST representation.

TEST=ci

Change-Id: I957583cb2ce9a3c408699880a04036e06b01dd31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501762
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2026-05-12 06:11:15 -07:00
Modestas Valauskas 754239b077 [core] Add trailingZeroBitCount and oneBitCount to int
Adds two new getters to int for bit-counting: trailingZeroBitCount
(ctz) and oneBitCount (popcount). On native platforms they operate
on the full 64-bit two's-complement representation; on the web they
operate on the least-significant 32 bits.

Implementations:
- VM: unified C++ natives Integer_trailingZeroBitCount /
  Integer_oneBitCount on _IntegerImplementation, using
  Utils::CountTrailingZeros64 and Utils::CountOneBits64. The receiver
  may be _Smi or _Mint at runtime.
- dart2js / DDC: clz32-based ctz and a SWAR popcount.
- dart2wasm: inlined i64.ctz and i64.popcnt intrinsics.

leadingZeroBitCount (clz) is intentionally excluded from this CL: its
result depends on the platform integer width (e.g. 1.leadingZeroBitCount
is 31 on web, 63 on native), and the same value can be derived from
the existing bitLength getter when needed.

Asm intrinsification on native architectures is intentionally left for
a separate follow-up CL.

Work towards https://github.com/dart-lang/sdk/issues/6486 (this CL
covers popcount and ctz from the bit-twiddling list; clz, rotate,
reverse, and others remain).

Work towards https://github.com/dart-lang/sdk/issues/1053 (efficient
BitSet implementation).

Bug: https://github.com/dart-lang/sdk/issues/52673
Bug: https://github.com/dart-lang/sdk/issues/38346
TEST=tests/corelib/int_bit_count_test

Change-Id: I8a5cdb5c91360478f47bbd6b9c84ca1c477aa8c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498041
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Modestas Valauskas <valauskasmodestas@gmail.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2026-05-12 05:49:31 -07:00
Johnni Winther 756dd1c665 [cfe] Use required type for lookup in map/list pattern
The members used to match a map/list pattern should be pulled from the required type and not the matched type in order to avoid wrongfully using extension type members.

Closes #63315

Change-Id: Idccc19fad1a3fc5cd1ecac2cfdb0ef0ee431d50f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502700
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-12 05:08:33 -07:00
Johnni Winther 9af6bae2e1 [cfe] Handle return; in extension type constructors
Since extension type constructors are lowered to top level procedures, the occurrence of `return;` must be lowered to `return #this;` where `#this` is the variable holding the this value.

Closes #63361

Change-Id: Ia9b444509767693107a911526de989e6a3c51180
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502900
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-05-12 05:05:29 -07:00
Konstantin Shcheglov 841afc1004 Augment. Parse augment factory.
Change-Id: I81df0fe9db49cb64fa81fbd737c44e364c868cf3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502186
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-12 00:24:55 -07:00
Brian Wilkerson d60a248196 Add a fix for empty_container_bodies
The fix replaces the empty braces with a semicolon.

Change-Id: Iadf423c1a3c08be2e67556ed9a33203238eb19a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502802
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-12 00:24:48 -07:00
Konstantin Shcheglov 67ce60fe48 BL-co19. Report optionalParameterInOperator for required named formal parameters.
Now pass:
co19/Language/Classes/Instance_Methods/Operators/optional_parameter_t10

Change-Id: Iee95a10d8bb68b980bcadaeb06aff92006ed3bb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502320
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-12 00:16:50 -07:00
Chloe Stefantsova 09a156bb2d [cfe] Make VariableBase.context independent from VariableBase.parent
Previously the getter VariableBase.context was redirecting to
VariableBase.parent, effectively requiring a change of the ownership
over the variable. This CL makes VariableBase.context a field of
VariableBase, allowing for the previously existing ownership structure
of the AST tree nodes.

The change allows to avoid workarounds for the existing
ownership-restoring logic, such as the assignments to the `parent`
pointer made in the constructors of the AST nodes and their
`transformChildren` and `transformOrRemoveChildren` methods.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I307c9d2b23c8201f8d7d2a100acf9fb8f3af2572
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494441
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-05-12 00:08:47 -07:00
Danny Tuppeny 3d339f3955 [analysis_server] Update normalizer benchmark test
We now have `:filePath` suffixes on the replacements when the input contained a file path (as opposed to a file URI).

Change-Id: I8b4a37aed669293169b8e8d148dab7f806506996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502680
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2026-05-12 00:08:41 -07:00
Chloe Stefantsova 7d2b344a7e [cfe] Fix printing of catch clauses with new CatchVariables
Since `CatchVariable`s don't have initializers, the print method in
the `Catch` node shouldn't attempt to print it.

Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I548e80e0f95c20a0537392faccd5c1fc11d844d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/497980
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-05-11 04:46:43 -07:00
Chloe Stefantsova 8df966741d [cfe] Update ast printing of new variable nodes
Part of https://github.com/dart-lang/sdk/issues/61572

Change-Id: I36f968d4dffc523af8e4f4c993d59b1b914110d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501641
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2026-05-11 04:46:26 -07:00
Martin Kustermann 96d8359e32 [dart2wasm] Cleanup closure related things
Move the creation of

* name of a lambda to `translator.functions.getLambdaFunctionName`
* type of a lambda to `translator.functions.getLambdaFunctionType`

Removes dependency on `w.FunctionBuilder` in the lambda code generators
- as they don't need access to the wasm function. This may allow
inlining closure calls in the future.

Avoid creating `w.FunctionBuilder` eagerly when analyzing closures and
instead create it only when there's a call to it (or the closure object
gets instantiated).

Use `CallTarget` abstraction when invoking lambdas.

Avoid carrying around
`(lambda, enclosingMember, enclosingMemberClosures)` throughout
the codebase and instead store this information on `Lambda`.

=> All these changes make the codebase more uniform between
   lambdas and normal functions and also is net code removal.

Change-Id: Ib69566ea9580827be0ed52c0c179884e84599d88
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501983
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-05-11 01:48:14 -07:00
Johnni Winther c2787e1cf4 [cfe][Contexts] Flatten variables hierarchy
This removes the LegacyVariableDeclaration and VariableInitializationBase classes to create a simpler hierarchy. This is done preparation for splitting variables from statements.

TEST=existing

Change-Id: If29c9eee1e3d8bed819ce53ed178c3efa3bffaea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501961
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-11 00:38:41 -07:00
Johnni Winther 4736248967 [cfe][Contexts] Associate scope with the replacement in visitBlock
This ensures that a [Block] that replaces the original block

Change-Id: I100d0a753d8f910e1b8439184eb1fb55c2c4c408
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501941
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2026-05-11 00:38:41 -07:00
Jens Johansen 63333c5b9c [dart2js] Speedup allowedNativeTest and make it more precise
*Before* https://dart-review.googlesource.com/c/sdk/+/501461 landed this
change caused the compile time for a large internal app to go from
`2m21.756s` to `1m43.366s`.

Now https://dart-review.googlesource.com/c/sdk/+/501461 did the same
change in runtime by changing the amount of times this is called.

Now I (probably) can't measure a difference on a whole run - but this
implementation is still 10 times faster (in a small benchmark asking
with the same uri many times goes from taking ~52 seconds to taking ~5
seconds).

Change-Id: Ibcfb7965e33f6d9517f62b4b31efa7ac66272d8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501940
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2026-05-11 00:38:02 -07:00
kevmoo b4f88f537b [dart2wasm] Fix spelling mistakes in the output mjs template
Fixes https://github.com/dart-lang/sdk/issues/63357

Change-Id: I8dec270e80616950ddb36ee3a1ac8b60798247c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502440
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
Auto-Submit: Kevin Moore <kevmoo@google.com>
2026-05-10 17:02:12 -07:00
Konstantin Shcheglov 6d6b2ae57f Augment. Report augmentationReturnTypeMismatch.
Add a compile-time diagnostic for augmentations that declare an explicit
return type different from the introductory declaration. Check top-level
functions, methods, and getters by comparing the augmentation annotation
against the introductory element return type using normal type equality.

Keep executable element return types initialized from the first fragment
only, so later augmentation fragments cannot overwrite the introductory
signature before validation. This also keeps synthetic getter/setter
variables based on the introductory declaration.

Change-Id: I08d55497e235ed2619a6915e0060bd5d8c8a45b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502200
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-09 11:44:34 -07:00
Erik Ernst 8028bd03fb Resolve test failures with web configurations
This CL adds code such that web compilers can recognize that `Let` nodes
can have a non-temporary variable as parameter. Before this CL, ddc
configurations fail in many anonymous method tests because the given
explicitly declared parameter isn't made available to the body of the
anonymous method.

Bug: https://github.com/dart-lang/sdk/issues/63184
Change-Id: I308c89e91e3856a06fa8f003d213cda0d93ae261
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/498060
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2026-05-09 07:13:11 -07:00
Konstantin Shcheglov d5ac7d4a57 AD. Use OwnedFiles to scope searches.
Use the collection-wide OwnedFiles map as the single source of truth for
deciding which analysis driver should process each file during search.
This replaces the per-query SearchEngineCache and SearchedFiles
ownership tracking with ownership recorded as files are discovered.

Store file paths, rather than URIs, in the analysis index so that
indexed element and subtype identifiers use the same File resources that
OwnedFiles tracks. Skip non-file sources when building or querying these
identifiers.

This lets search operations discover available files up front and then
search only files owned by the current driver. It avoids duplicate work
and duplicate results across drivers while keeping search ownership
consistent for references, subtypes, member declarations, top-level
declarations, and workspace symbols.

Bug: https://github.com/dart-lang/sdk/issues/63276
Bug: https://github.com/dart-lang/sdk/issues/63310
Change-Id: I27feed534cb84f52bffbd4da0c53e5c669910b1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-08 17:27:21 -07:00
Konstantin Shcheglov d675a04fd1 Augment. Report augmentationModifierExtra and augmentationModifierMissing.
Report augmentationModifierExtra and augmentationModifierMissing when an
augmenting class or mixin does not use the same modifiers as the
introductory declaration.

Check class augmentations for abstract, base, final, interface, sealed,
and mixin modifiers. Check mixin augmentations for the base modifier.

Keep the explicit syntactic abstract modifier on class fragments
separate from the semantic abstract state in the class. This lets sealed
declarations continue to produce abstract class elements without making
their fragments appear to have an explicit abstract modifier, so
augmentation modifier checks can distinguish sealed from abstract
sealed.

Change-Id: I169e16c7b7363802d91882759550264f1c96f026
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502183
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-08 16:50:09 -07:00
Konstantin Shcheglov a5057b29b7 Augment. Move isCompleteDeclaration computation to AST.
So that we can use the same implementation for unlinked api signatures
and for the fragment builder.

Change-Id: Icdf230997234e83be5f9f49ac5febb205775807e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502201
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-08 16:49:16 -07:00
Nate Biggs f31923beee [dart2wasm] Fix async* stream not forwarding errors to listener cancel.
Set up a cancellation Completer that we forward errors to if the stream
has been cancelled.

Also add `isDone` which will avoid forwarding registering the
cancellation logic if the stream has already finished.

Fixes test
co19/Language/Expressions/Function_Invocation/async_generator_invokation_t10.dart
on wasm targets. This test already passes for all other backends.

Fixes: https://github.com/dart-lang/sdk/issues/63123
Change-Id: I8a3d87c3ea7b4ebb3a7b82ab064fb57034aa6f4a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/495200
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-05-08 15:39:19 -07:00
Brian Wilkerson f7c06eb180 Add a new lint to find container bodies that could be a semicolon
The purpose of this lint is to be used with other lints to maximally
convert code to using the new features introduced by the primary
contructors feature. This one is targeted at finding container bodies
the could be replaced by a semicolon.

This CL does not include a fix. That will be added in a separate CL.

We will need to decide whether this lint is worth supporting beyond
the testing period.

Change-Id: I5d2d05117c9f1efc8c71279d5cde549eb48b480c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502182
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2026-05-08 13:55:19 -07:00
Nicholas Shahan 77c65d60ec [ddc] Fix type in matcher in scope offset test
It looks like the type expectation in the block visitor of this test
has always been wrong and we might have never visited a block before.

It looks like fixing the failing type expectation reveals an actual
failure that this test is trying to catch: The block node doesn't
have a valid offset.

Issue: https://github.com/dart-lang/sdk/issues/63226
Change-Id: I4b8d7b60350b627e10a974a2d794db1973b3fff1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502184
Reviewed-by: Nate Biggs <natebiggs@google.com>
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2026-05-08 12:57:06 -07:00
Brian Wilkerson 157baccaa5 Add a fix for use_primary_constructors
The use_primary_constructors lint is a temporary lint being used (along
with others) for testing the primary constructors feature. I don't
expect that it will ship to users in its current form, so these fixes
might be removed.

With that in mind, I updated the existing assist that can convert a
secondary constructor to a primary constructor so that it can be used
as a fix. (The assist will remain, even if the lint is removed.) I then
added a second fix to add a primary constructor when there are no
explicit constructors. I did this for two reasons:

1. I expect the fix to be removed before the feature is shipped because
   it seems unlikely that users would want to have an explicit primary
   constructor rather than the implicit default constructor.

2. Making it a separate lint allows it to have a better label on the
   context menu in case users actually see it during the beta period
   (or in the stable version if I'm wrong about #1.

The effect is that the lint can now be bulk fixed in order to maximally
convert a body of code.

Change-Id: I7c6dddd8735e67bbd1d398e4035ca578725d044f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502180
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2026-05-08 12:51:13 -07:00
Konstantin Shcheglov b7e77d98a9 Augment. Implement and re-enable augmentationExtendsClauseAlreadyPresent.
Change-Id: I2d20fc111d119f6ab7939edc57aa46f3930e76e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/502181
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-08 12:43:14 -07:00
Nicholas Shahan de18b40933 [ddc] Split hot restart into two phases
Exposes two new methods `hotRestartBegin()` and `hotRestartEnd()` in
the `DartDevEmbedder`. This provides a more customizable loading
of sources across the variety of environments we are supporting.

Change-Id: Id7a35695234f0625fe4de1d67c9d5a8055bad461
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/500240
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2026-05-08 11:43:35 -07:00
Konstantin Shcheglov 377c02e4d0 CQ. Reflow code snippets in element model tests.
Format code snippets for better readability and consistency. Update the
affected expected element text offsets where the source layout changed.

Change-Id: Ifd60ebdbfa4d79d1b30a06734c92c321bd9ad00f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501701
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-08 10:26:22 -07:00
Konstantin Shcheglov 3fa973a3cb Augment. Report augmentationTypeParameterBound.
Report augmentationTypeParameterBound when an augmentation writes a type
parameter bound that is not the same as the introductory declaration's
bound. This covers declarations and executable members, including class
methods and top-level functions.

Keep the element bound from the introductory fragment when resolving
type parameters. Augmentation fragments should not overwrite that bound,
so the verifier can compare the written augmentation bound against the
original declaration.

Change-Id: I13f8ef160f081a581d394b9afe9b7bb1d119d0d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/501760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2026-05-08 08:32:43 -07:00