Commit graph

23094 commits

Author SHA1 Message Date
MarkZ 210e120fbd [ddc] Creating a hot reload and hot restart test suite.
The hot reload runner currently only supports d8, but I plan to add support for Chrome and VM execution.

Notable changes:
* Creates `package:reload_test` with helpers for running this suite.
* Updates the module loader with D8-specific branches and hooks for hot reload/restart.
* Exposes DDC runtime variables via a `HotReloadTestRuntime` API.
* Ports constant equality hot restart tests from webdev/dwds (validated to fail if either cache-clearing mechanism fails).
* Partially rolls DDC's d8 preamble forward (towards dart2js's).
* Wraps D8's timer implementation with custom timeout logic to better match Chrome's timing semantics when executing with native JS async.

Tests for the framework and matrix updates will be added in an upcoming change.

Change-Id: I2773b29f464cfd0330e4c653c05e117ae150b4a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350021
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2024-03-05 00:12:18 +00:00
Srujan Gaddam e1834792c3 [dart:js_interop] Fix comparison operator return types
Fixes https://github.com/dart-lang/sdk/issues/55024

The patch files for these operators return a bool, whereas
the public API returns a JSBoolean. Since there's only one
possible return type, we should make them return bool for
convenience. Boolean conversion is also inexpensive on
dart2wasm, so that shouldn't be an issue.

Also adds helpers to operator_test to make sure any JS values
are converted before they're compared, adding additional type
checking through the conversion.

CoreLibraryReviewExempt: Fixes type mismatch in backend-specific library.
Change-Id: I7ff2e334e817e6e7d7d8d5091a4e5d570a496b03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354702
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-03-04 21:10:02 +00:00
Paul Berry b279238e48 Implement context-aware type analysis for conditional-like expressions.
In the following expression types, the static type is computed using
the least upper bound ("LUB") of their subexpressions (adjusted as
appropriate to account for the null-shorting behaviors of `??` and
`??=`):

- Conditional expressions (`a ? b : c`)
- If-null expressions (`a ?? b`)
- If-null assignments (`a ??= b`)
- Switch expressions (`switch (s) { p0 => e0, ... }`)

This can lead to problems since the LUB computation sometimes produces
a greater bound than is strictly necessary (for example if there are
multiple candidate bounds at the same level of the class hierarchy,
the LUB algorithm will walk up the class hierarchy until it finds a
level at which there is a unique result). For a discussion of the kind
of problems that can arise, see
https://github.com/dart-lang/language/issues/1618.

This change improves the situation by changing the analysis of these
four expression types so that after computing a candidate static type
using LUB, if that static type does not satisfy the expression's
context, but the static types of all the subexpressions *do* satisfy
the expression's context, then the greatest closure of the context is
used as the static type instead of the LUB. This is the algorithm
proposed in
https://github.com/dart-lang/language/issues/1618#issuecomment-1507241494.

This is theoretically a breaking change (since it can change code that
demotes a local variable into code that doesn't, and then the demotion
or lack of demotion can have follow-on effects in later code). So it
is implemented behind the `inference-update-3` experiment
flag. However, in practice it is minimally breaking; a test over all
of google3 found no test failures from turning the feature on.

Since one of these expression types (switch expressions) is
implemented in `package:_fe_analyzer_shared`, but the other three are
implemented separately in the `package:analyzer` and
`package:front_end`, this change required modifications to all three
packages. I've included tests for the new functionality, following the
testing style of each package. I've also included a comprehensive set
of language tests that fully exercises the feature regardless of how
it's implemented.

Since `package:front_end` has many different implementations of `??=`
depending on the form of the left hand side, I've tried to be quite
comprehensive in the language tests, covering each type of assignable
expression that might appear to the left of `??=`.

Change-Id: I13a6168b6edf6eac1e52ecdb3532985af19dbcdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353440
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-03-04 17:19:00 +00:00
Lasse R.H. Nielsen 9d933d1281 Retire 3.3 experiments in the 3.4 release.
Tested: No new tests.
Change-Id: Idf19ce8b6743b221841e6cef6b2a80e8ab37860e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354260
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-03-04 16:09:31 +00:00
Srujan Gaddam 0d93e05db4 Check that object literals do not contain parameters
Modifies a test to check that object literals that are
assumed to not contain a parameter actually don't
contain that parameter.

Change-Id: I2e7952c696ed22cd2d8e59d72cb1a537a61c6b6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355202
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-02-29 22:11:15 +00:00
Vyacheslav Egorov 9e11d79657 [vm] Remove dart:cli waitFor
Closes https://github.com/dart-lang/sdk/issues/52121

Tested: CI
CoreLibraryReviewExempt: Approved breaking change to VM specific code
Change-Id: Icc89017c5a7676c2ae07488692ad8b8b9e131a7f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354880
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-02-29 11:18:51 +00:00
Chloe Stefantsova 3ef08e1ecd [analyzer][cfe] Expand TypeAnalyzerOperations. Part 1
This CL adds more of the type operations required in the subtype
constraint gathering algorithm into the shared type operation
class. The added operations are used in the constraint gathering
algorithms in the Analyzer and the CFE.

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

This is a reland of
https://dart-review.googlesource.com/c/sdk/+/346840

Change-Id: I99086cfc3cd56db40055e9bb8e23acec8bdf830b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354622
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-02-29 08:14:20 +00:00
Lasse R.H. Nielsen 1436635d27 Add more information to ParalleWaitError.toString.
Gives the constructor optional parameters for providing
more information that can be used in the `toString` message,
and the `stackTrace` getter.
Makes the `iterable.wait` and `record.wait` extension methods
provide such information, so that the `toString` will always
contain the text of *one* of the errors.

(No issue, problem with logging was brought up in chat.)

Change-Id: I5f9a20ad0af0c64a2e7ff3cdb56f187a5cf5a3ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353080
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-02-28 20:36:58 +00:00
Erik Ernst ca220074db Add test about "T derives the future type U"
Issue https://github.com/dart-lang/sdk/issues/54628 raised the issue
that the static analysis of `await e` behaves in unexpected ways when
the static type of `e` is a subtype of a future related type, rather
than just a plain `Future<T>` or `FutureOr<T>` for some `T`.

This CL adds a test that assumes the update to the language
specification which is performed by the PR
https://github.com/dart-lang/language/pull/3574. Hence, this CL
should ONLY BE LANDED if and when that PR is landed.

Change-Id: Ib8acb77e24ffbceb0b4034d3b23a0f4fef8e3d1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354020
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-02-28 19:44:45 +00:00
Erik Ernst 3f4f10bd0f Update void usage test to new test runner expectations
The old version of language/void/void_type_usage_test.dart had some
faults (compile-time errors were expected, but they weren't reported
by tools and yet the test run succeeded). The failures were caused by some amount of duplication in the labels (a handful of duplicate labels from a set of about 450 labels, that is, it wasn't immediately obvious). This CL updates the test to use the new test expectation syntax (`//  ^^^^`) and adjusts the expectations to match the currently reported error messages, plus the ones about `void` that are missing.

Note that this test went through a phase where I believed that we had about 260 failures (130 CFE and 130 analyzer), but they turned out to be a consequence of migrating this test incorrectly from being a multi test into a form where it uses the current test expectation comments (`// ^^^` and such). At this point we just have 3 failures (all on expressions of the form `e += 1`), all with the CFE.


Bug: https://github.com/dart-lang/sdk/issues/31883
Change-Id: Ib1ceb56326a5847e3ca23ac0ee655eee65f0d76f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350921
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-02-28 18:30:20 +00:00
William Hesse 83ba5916b7 [vm] Skip a slow test in aot debug mode (#21708)
The test LibTest/collection/ListBase/ListBase_class_A01_t02 takes
more than 10 minutes to be precompiled in debug mode, due to
a known issue.

Skipping this test on the CI and CQ  because it causes deflaking problems
when timing out. The problem is being tracked already in an issue.

Bug: https://github.com/dart-lang/sdk/issues/54974
Bug: https://github.com/dart-lang/sdk/issues/21708
Change-Id: Ib05e0f18baac684cf3317dbc2171a5a585e04f98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354844
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-02-28 15:28:39 +00:00
Martin Kustermann c57ad70588 [gardening] Make test not run in obfuscated/dwarf mode
TEST=Fixes standalone/regress_53519_test in obfuscate/dwarf mode

Change-Id: I6bd87ffbc983e7a429b2c0728a09ac3ccfd6d280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354840
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-28 10:27:11 +00:00
Liam Appelbe 56dcacff5c [test] Weaken regex in regress_53519_test.dart
Apparently in AOT mode there's no column number:
https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8754902661978664065/+/u/test_results/new_test_failures__logs_

TEST=tests/standalone/regress_53519_test.dart
Change-Id: I06f97d8738d0f1228953fbfbf2006302defec1a8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354820
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2024-02-28 02:22:09 +00:00
Lasse R.H. Nielsen f0aeebd0e7 Make all platforms return null from Error.stackTrace until thrown.
The web platforms used to invent a spurious stack trace when reading
`Error.stackTrace` before the object was thrown.
They now return `null` instead, if there is no underlying JS error object,
matching specified behavior.

Fixed bugs in async error throwing in dart2wasm:
* `throw` in an async function did not set the stack trace on an error.
  Now calls `Error._throw` instead of just a direct Wasm "throw".
* `async*` functions did not capture the stack trace of a throw
  that ended the function body, which means it called
  `StreamController.addError` with only one argument.
  That then resused the stack trace from an `Error` throw instead
  of the correct stack trace.

Added tests.

Change-Id: I1d9fa8d9e18076a7fe28254b60b950866cd550a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354021
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-02-27 23:01:06 +00:00
Liam Appelbe 44094abe2f [vm/service]: VM plumbing for Throw.forErrorHandling
Use the new Throw.forErrorHandling AST flag to ignore synthetic error
handling statements in coverage. When the flag is found on a throw node,
all the TokenPositions on the child nodes are set to kNoSource.

Questions for reviewers:
- Are there any VM use cases that need the real TokenPosition here?
- Is there a better way of encoding this flag in the TokenPosition?
- Should we add a new sentinel TokenPosition instead?

Bug: https://github.com/dart-lang/sdk/issues/54005
Fixes: https://github.com/dart-lang/sdk/issues/53519
Fixes: https://github.com/dart-lang/sdk/issues/54941
Change-Id: Ic44fe2fa0359188b890d5ed762e3ff8c593c850d
TEST=SourceReport_Regress53519_Destructuring
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353920
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2024-02-27 21:59:50 +00:00
Martin Kustermann 3c218ecc53 [dart2wasm] Work around V8/Chrome bug that swallows exceptions from rethrows
Issue https://g-issues.chromium.org/issues/327155548

Change-Id: I7babc0bcfad3e4351af08ce3accb61db6260d86b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354227
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: William Hesse <whesse@google.com>
2024-02-27 14:00:32 +00:00
Tess Strickland 12e7895d2e [gardening] Fix off-by-one error introduced after added import.
https://dart-review.googlesource.com/c/sdk/+/352863 added an import
before the lines that throw an error, causing the checks in these two
tests to be off by one.

TEST=standalone/dwarf_stack_trace_invisible_functions
     standalone/dwarf_stack_trace_obfuscate

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-arm64-try,vm-aot-linux-release-x64-try
Change-Id: Ia2830bf6b49d991bb21a9973acb4c1888f9f441b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354222
Auto-Submit: Tess Strickland <sstrickl@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2024-02-27 11:41:45 +00:00
Martin Kustermann 511a41a3b9 [dart2wasm] Skip timing out tests that hang test runner
Those timing out tests cause CI infra issues (purple bots)
on deflaking.

Issue https://github.com/dart-lang/sdk/issues/55025

Change-Id: Ibdc3766e0e482f180c03acc987c3323a3574647c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354621
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Auto-Submit: Martin Kustermann <kustermann@google.com>
2024-02-27 11:22:51 +00:00
Konstantin Shcheglov 63f28de439 Augment. Update language/augmentation_libraries/class_augmentation_test
Change-Id: I979e22e7d6dfd9ef42b94e7d0868123359a104b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354480
Reviewed-by: Jake Macdonald <jakemac@google.com>
2024-02-27 01:54:00 +00:00
Konstantin Shcheglov fe41579bf6 Macro. Update JsonSerializable to use throw instead of invalid code.
Bug: https://github.com/dart-lang/sdk/issues/55005
Change-Id: I7ba716576ef5c4cb3aef1e4bd10c70824d39964a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354120
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2024-02-26 18:22:47 +00:00
Martin Kustermann c625797f8a [dart2wasm] Implement dart:developer in dart2wasm
* We migrate the `dart:developer` implementation of dart2js to
static interop.

* We make dart2wasm use the same implementation as dart2js.

Closes https://github.com/dart-lang/sdk/issues/54991

Change-Id: I7873edc7e804500c8eca878367d9045c98a1c2e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354101
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-02-26 11:23:29 +00:00
Konstantin Shcheglov e5520938b1 Macro. Support for TypeAliasDeclaration in typeDeclarationOf().
This covers a failure in language/macros/json/json_serializable_diagnostics_test.dart

Change-Id: I751a58db6316ef2d9bb42533e279ab5fa49d1fd0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/354042
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-02-23 21:56:59 +00:00
Martin Kustermann 854b68f04a [dart2wasm] Fix incorrect elimination of type argument checks.
The change in [0] was somewhat finishing RTT checks but didn't
fix that part correctly. A later fix to that code in [1] also
didn't fix the underlying issue.

[0] https://dart-review.googlesource.com/c/sdk/+/249641/22/pkg/dart2wasm/lib/types.dart#471
[1] https://dart-review.googlesource.com/c/sdk/+/292881 (which got
relanded)

Closes https://github.com/dart-lang/sdk/issues/54994
Issue https://github.com/dart-lang/sdk/issues/54998

Change-Id: I507070514e98cb66a57f4f7f08906a32993265d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353900
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-02-23 14:16:01 +00:00
Sergey G. Grekhov fe4ae77b22 [co19] In AOT mode turn-off tests that uses mirrors
`dart:mirrors` is not supported in AOT mode.

Bug: https://github.com/dart-lang/co19/issues/2546
Change-Id: I2b0d42df911c6f185e72239f4786a87c535de535
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353522
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Sergey Grekhov <sgrekhov22@gmail.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-02-23 08:01:59 +00:00
David Morgan e680eb4c4f [macros] Tweak diagnostic for unexpected macro implementation exception.
The only expected exceptions at this point are DiagnosticException and MacroException subtypes; everything else is a bug in the implementation.

Tweak the diagnostic to explain that it's due to a bug in the macro. Add the exception message and stack trace as a context message, and a fix hint to contact the author.

Add a language test.

Retry landing with updates to `pkg/analyzer/test/summary/macro_test`.

R=jensj@google.com, scheglov@google.com, sigmund@google.com

Change-Id: Iebc3df784922dcb6ef112ba8d023d5388516373b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352361
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-02-22 13:53:20 +00:00
Brian Quinlan b4574904f9 [io] Fix a bug where relative symlinks to directories did not work on Windows.
Also modified `File::GetType` on Windows to correctly report the type of broken links as notFound.

Windows fixes:
co19/LibTest/io/Link/createSync_A04_t08
co19/LibTest/io/Link/createSync_A04_t10
co19/LibTest/io/Link/createSync_A04_t12
co19/LibTest/io/Link/createSync_A04_t14
co19/LibTest/io/Link/createSync_A04_t16
co19/LibTest/io/Link/createSync_A06_t01
co19/LibTest/io/Link/createSync_A06_t03
co19/LibTest/io/Link/createSync_A06_t06
co19/LibTest/io/Link/createSync_A06_t08
co19/LibTest/io/Link/create_A04_t08
co19/LibTest/io/Link/create_A04_t10
co19/LibTest/io/Link/create_A04_t12
co19/LibTest/io/Link/create_A04_t14
co19/LibTest/io/Link/create_A04_t16
co19/LibTest/io/Link/create_A06_t01
co19/LibTest/io/Link/create_A06_t03
co19/LibTest/io/Link/create_A06_t06
co19/LibTest/io/Link/create_A06_t08
co19/LibTest/io/Link/resolveSymbolicLinksSync_A01_t01
co19/LibTest/io/Link/resolveSymbolicLinks_A01_t01


Bug:https://github.com/dart-lang/sdk/issues/53848
Bug:https://github.com/dart-lang/sdk/issues/45981
Change-Id: I3d156f38540089d8adb12dbb79d0477330d9eb07
Tested: updated unit tests plus fixes existing tests
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335940
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-02-21 20:20:02 +00:00
Sergey G. Grekhov 5e83b53f97 [co19] Roll co19 to 867d139b3169fc131488e893ec1133dc98cc3aa0
2024-02-20 sgrekhov22@gmail.com dart-lang/co19#2496. Add missing part file (dart-lang/co19#2552)
2024-02-20 sgrekhov22@gmail.com dart-lang/co19#2549. Update built-in identifier tests. Add missing ones. Part 2 (dart-lang/co19#2551)
2024-02-20 sgrekhov22@gmail.com dart-lang/co19#2549. Update built-in identifier tests. Add missing ones. Part 1 (dart-lang/co19#2550)
2024-02-19 sgrekhov22@gmail.com Fix dart-lang/co19#2546. Add constant context tests (dart-lang/co19#2547)
2024-02-15 sgrekhov22@gmail.com Fixes dart-lang/co19#2496. Fix co19 tests that became failing after test runner update (dart-lang/co19#2497)
2024-02-14 sgrekhov22@gmail.com dart-lang/co19#1400. Add cascade operator test and more constants tests (dart-lang/co19#2545)
2024-02-14 sgrekhov22@gmail.com dart-lang/co19#2350. Add more factory constructor tests (dart-lang/co19#2543)
2024-02-14 sgrekhov22@gmail.com dart-lang/co19#1400. Add representation variable initialization test (dart-lang/co19#2544)
2024-02-13 sgrekhov22@gmail.com dart-lang/co19#2119. Remove unsupported element from Stream.first/lastWhere tests description (dart-lang/co19#2540)
2024-02-13 sgrekhov22@gmail.com dart-lang/co19#2119. Remove unsupported element from ReceivePort.first/lastWhere tests description (dart-lang/co19#2541)
2024-02-13 sgrekhov22@gmail.com dart-lang/co19#2339. Add more tests for the extension method with the name `type` (dart-lang/co19#2542)
2024-02-12 sgrekhov22@gmail.com Fix dart-lang/co19#2535. Add patterns constants tests for extension types (dart-lang/co19#2539)
2024-02-12 sgrekhov22@gmail.com Fix dart-lang/co19#2485. Update`as` and `is` expressions tests with a function type (dart-lang/co19#2538)
2024-02-12 sgrekhov22@gmail.com Fix dart-lang/co19#2536. Fix use of HINT.UNREACHABLE_SWITCH_CASE (dart-lang/co19#2537)
2024-02-09 sgrekhov22@gmail.com dart-lang/co19#2119. Remove unused code, add issues numbers (dart-lang/co19#2534)
2024-02-09 sgrekhov22@gmail.com dart-lang/co19#2529. Fix failing API core tests (dart-lang/co19#2533)
2024-02-09 sgrekhov22@gmail.com dart-lang/co19#2529. Delete API tests with compile-time errors (dart-lang/co19#2531)
2024-02-09 sgrekhov22@gmail.com dart-lang/co19#2529. Fix and enable Iterable/forEach_A03_t01 (dart-lang/co19#2532)

Change-Id: I03e721d3871d5bf2b9773fbf7ebadb2a1804a111
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353260
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-02-21 15:56:27 +00:00
Paul Berry 4d1c8b09cb Fix context for the RHS of the invocation of an extension setter to match analyzer.
This looks like it was an oversight--previous to this change, there
was zero test coverage for this case.

Change-Id: I4301a3ba90aedce3b0fcd901649c370cba522f4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353280
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-02-21 15:10:18 +00:00
Ömer Sinan Ağacan 2da70a8d9e [dart2wasm] Improve closure hash codes
Currently hash code for a closure is the hash code of it's runtime type.

This causes a lot hash collisions in some apps and cause performance
issues.

With this patch we now use captured objects in closures when calculating
hash codes.

The hash codes are now:

- For tear-offs:

    mix(receiver hash, closure runtime type hash)

- For instantiations:

    mix(instantiated closure hash,
        hashes of captured types)

  Note that an instantiation can be of a tear-off, in which case
  "instantiated closure hash" will calculate the tear-off hash as above.

- For others (function literals, static functions), the hash is the
  identity hash.

Fixes #54912.

CoreLibraryReviewExempt: Mark private corelib function as entry-point in Wasm
Change-Id: I6a123fdc690237f543bb8bf832f0f8119d013a55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353162
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-02-21 14:44:20 +00:00
Sergey G. Grekhov 3b52517bca [test] Add support of dart2wasm.status in co19 tests
Fixes: #54971

Change-Id: I033c8ba78e6cdcf26dce9cae8998308a595a37e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353262
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2024-02-21 14:03:23 +00:00
Paul Berry fa38f392fa Fix context for null-aware extension method invocations to match analyzer.
This looks like it was an oversight--previous to this change, there
was zero test coverage for this case.

Change-Id: Icba1381c389af37ab4fe38f345cc78fe6c01d7f9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/353226
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-02-21 13:13:07 +00:00
Lasse R.H. Nielsen e86b08e5bb Forwards ignore bit to chained-to _Future.
If a target `_Future` is chained to another source `_Future`,
then it's because the target will complete with the same
result as the source future. Instead of keeping both
alive with a listener on the source which completes the target,
instead the target moves all its listeners to be directly on
the source, and keeps a link to the source in case more listeners
are added later.
The idea is that most futures are unreferenced after they have
had their first listener, so the target future has a chance
to be GC'ed.

If the target future has `.ignore()` called, and has no listener,
then the source completing with an error should not cause the
error to be uncaught. Without the optimization, the source would
have had a listener, and the target would ignore the error.

To simulate that, the source now gets a copy of the target's
`_ignoreUnhandledErrors` flag.

This is still not precisely the same as it would be without the
optimization. If *two* target futures are chained to the same source,
and only one of targes has `.ignore()` called, then this
implementation will make the uncaught error not be reported,
where it technically should.

(An alternative would be to *not* use chaining for futures
with `ignore()` called on them. But those are precisely futures
that are likely to be GC'able, because someone has already said
that they don't care if the future complete with errors.)

Fixes #54943

Bug: https://github.com/dart-lang/sdk/issues/54943
Change-Id: I0dbb4919ce2ea612d66539862fa0eb188aab8287
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352908
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2024-02-21 13:05:56 +00:00
Srujan Gaddam e9678f72de [dart2js] Handle object literal constructors with no library @JS annotation
Fixes https://github.com/dart-lang/sdk/issues/54801

Object literal constructors need to be explicitly handled when
determining a member is JS interop or not in dart2js as it does
not require any @JS annotations.

Change-Id: Iee99375439057844485aa3f5cd88f85f5d03ae06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349840
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-02-20 23:59:24 +00:00
Paul Berry 32ab547688 Fix analyzer handling of record literal type inference.
This CL contains several small bug fixes:

- The context is only used for type inference if it is a record type
  with the same shape as the record literal. Previously, if the
  context was a record type with a different shape than the record
  literal, the analyzer would attempt to do an approximate match
  (using the context from any matching named fields, and from all the
  positional fields that were in common between the context and the
  literal). At first glance, it might seem like this would only matter
  for erroneous code (since record shape mismatches typically lead to
  compile-time errors). But if the context arises from a local
  variable promotion, then a mismatch doesn't lead to a compile-time
  error; it simply leads to a demotion. So the difference is
  observable for non-erroneous code.

- If one of the fields is implicitly downcast from `dynamic`, the
  static type of the field's expression remains `dynamic`. This makes
  the behavior of dynamic downcasts inside field literals consistent
  with all other implicit dynamic downcasts.

- If one of the fields is implicitly downcast from `dynamic`, the
  downcast is made to the greatest closure of the context. Previously,
  the downcast was made to the context itself, which meant that it was
  possible to create static types containing the unknown type,
  violating one of the key assumptions of the Dart type system.

- If one of the fields has a static type of `dynamic`, and `dynamic`
  is a subtype of the greatest closure of the context (e.g. because
  the context is `Object?`), no dynamic downcast is
  performed. Previously, a dynamic downcast _was_ performed, meaning
  that the static type of the resulting record literal would have
  `dynamic` in a spot where `Object?` should be.

This brings the analyzer behavior into line with the spec and the
front end, with one minor exception:

- When the front end uses the greatest closure of the context to
  implicitly downcast a field from dynamic, it uses a modified
  greatest closure algorithm where covariant instances of `_` are
  replaced with `dynamic` instead of `Object?`.

The front end's behavior in this rare case doesn't agree with the
spec; I'll address this in a future CL.

Change-Id: Ib1ab7ee4d0f63a152480704e2c0d5332446a613c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/350983
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-02-20 20:21:48 +00:00
Erik Ernst bf17088787 Add test about types being incompatible with await
PR https://github.com/dart-lang/language/pull/3560 and
https://github.com/dart-lang/language/pull/3598 updated the feature
specification of extension types to define a notion of types being
'incompatible with await'. This CL adds a test to verify that various
types are being classified correctly, and errors are hence reported
as expected for expressions of the form `await e`.

Change-Id: I39e992b4317ef49fbc2267819481d71d87b56aca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351143
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2024-02-20 16:49:49 +00:00
David Morgan 980cf725ff [test] Check all local files for error strings.
Based on abandoned change #264261.

Changes to that PR: compare and show file paths, improve part parsing, include analyzer expectations from other files as well as CFE expectations, update unit tests.

Add end to end tests. The simplest case "library_failure_test.dart" passes before this PR, all others require the change in this PR to pick up expectations in other files.
Change-Id: Ia71b78a8f0dced83f603309877132f261b47c5a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345541
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2024-02-20 09:31:21 +00:00
Chloe Stefantsova 59eb20c04d Test collecting constraints in extension type vs non-extension types
Part of https://github.com/dart-lang/sdk/issues/54902

Change-Id: I142b57ddddba4e701a1c39af0e90f98f573635be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352861
Reviewed-by: Paul Berry <paulberry@google.com>
2024-02-19 10:41:00 +00:00
Brian Quinlan 770f44d4e9 [io] Make it possible to change the line ending output by stdout and stderr.
There is a performance impact in:
`stdout.lineTerminator = "\r\n";`

For small writes (<100 chars), the performance loss is lost in the noise of the `write` system call.

For writes of ~500 chars, the performance is about half of that without line terminator translation. But, on a M2 Mac laptop, ~80M characters can be written per second.

Bug: https://github.com/dart-lang/sdk/issues/53161
Change-Id: Icfa0f981dcf6edb856d8aac5e0e270bc0148d498
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/326761
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2024-02-16 20:06:03 +00:00
Daco Harkes ca9eb4af0f [gardening/test] Cleanup AOT checks in tests
Change-Id: I5235c5ba9824f72806214528ed86ecca2f3a7630
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352863
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-02-16 16:39:09 +00:00
Ömer Sinan Ağacan 2bdcfb7035 [dart2wasm] Fix instantiation closure equality
We can't generate a virtual call to `Object.==` in generated code as
`Object.==` may not be added to the dispatch table, even with
`@pragma(wasm:entry-point)`.

Instead this adds a top-level `_runtimeTypeEquals` function that calls
`==` on the `_Type` argument. Effectively this forces adding `_Type.==`
to the dispatch table and calls it virtually.

Fixes #54926.

Change-Id: Ice3306ed00f66c8abedb3ef11b58c15296457eb0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352900
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-02-15 17:33:01 +00:00
Martin Kustermann d3d83e639c [vm] Do not bundle dart.lib in the Dart SDK
Users of our standalone embedders we distribute in the Dart SDK should
be using `dart_api_dl.h` (and initialize it from
the `dart:ffi`s `NativeApi.initializeApiDLData`)

If there's any API functions missing, we can add them.

Though we should not Dart C API symbols that are only relevant for
embedders. It requires a custom embedder implementation (which is
outside the scope of what we distribute in Dart SDK)

Issue https://github.com/dart-lang/sdk/issues/40579

TEST=ci

Change-Id: I6f3842668c59a5dd6fefc6857581995501b9b0e0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352820
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-02-15 14:09:37 +00:00
David Morgan dc586994da [macros] Add language tests for nested macros and disallowed macro use.
Nested macros: check that macro impls can themselves use macros.

Disallowed use: check that macros can't be used in the library in which they are declared, or in the same library cycle.

R=jakemac@google.com

Change-Id: I3b12afc27e5784edc217508b7763a9b448229877
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352522
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
2024-02-15 09:42:41 +00:00
Stephen Adams 4df361c3c3 Reapply "[dart2js] Replace phi with controlling condition"
This reverts commit aec3ec0244.

- Corrected 'controlling condition' detection.
- Added test that is incorrectly compiled to infinite loop with incorrect controlling condition detection.

See https://github.com/dart-lang/sdk/issues/54115#issuecomment-1944285230 for an image of part of the CFG for `doWhileLoop` where the condition in B4 was previously mis-identified as controlling `phi(true,false)` at B12.

Issue: #54115
Change-Id: I0d2c2ff83b202071f6d7050d34de8ff25d05cb22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352443
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-02-15 01:02:39 +00:00
Sigmund Cherem 2c71cecc0c [tests] update function tests to use Expect.throwsWhen
Change-Id: I0b909305baea9110fd90423850be5850d7a1a83a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351720
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-02-15 00:45:52 +00:00
Nicholas Shahan b955d6a628 [ddc] Delete variance tests for old DDC types
- These tests rely on the internals of the old type system.
- Copy some expectations to the language suite when it looks like
  there isn't already coverage for the same test.

Change-Id: I63bfa2bc94fb29b4e4f90c3c02cf0943d19764b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352463
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2024-02-14 22:29:33 +00:00
Sigmund Cherem 9a9f23fd35 [tests] update await_for_test to test behavior variations.
This introduces an asyncExpectThrowsWhen to async_helper, similar to
Expect.throwsWhen, to allow specifying semantics under behavior
variations in this test.

We also update await_for_test to no longer skip expectations in dart2js.

Change-Id: Ie147f74f384a0e196e40b75c59fe585f011ede49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351721
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-02-14 21:43:47 +00:00
Sigmund Cherem 050afd650f [expect] introduce Expect.throwsWhen and Expect.throwsTypeErrorWhen
Today, most tests that touch on a behavior variation end up
skipping expectations or the entirety of a test for some
testing configurations.  Moving forward, we'd like skip less
and try to account for the behavior variations if that's
reasonable.

This CL shows an approach to improve our test coverage for
behavior variations. We introduce two new methods to
[Expect] that allow us to conditionally check that a
function throws, depending on variation predicates.

The CL changes expectations for errors that don't occur
when dart2js omits parameter type checks or implicit
downcasts.

Note: originally I had the intention to introduce a name
parameter to `Expect.throws` and `Expect.throwsTypeError` to
avoid introducing a new API. However, because these APIs are
used for testing core language features, such as function
parameters themselves, we decided to keep the use of
features in these APIs as simple as it can be.

CoreLibraryReviewExempt: no public library semantic change - only improving test coverage under variations
Change-Id: I531657622655778491eaca8b37ba69ffaab559fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/351340
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-02-14 20:12:05 +00:00
Nicholas Shahan a92ac0237a [ddc] Delete tests requiring the old type system
These are tests for the specific apis of the old runtime type system
and they will never pass in the new type system.

Change-Id: I740fc06411cdc621b072782d22ec630c5b6bf96a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/341784
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-02-14 00:13:57 +00:00
Jake Macdonald 2624743bdd handle deserializing metadata diagnostic targets
Change-Id: I47f747baf48d6fc3a0e04871990d0743dbbb41e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352560
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Auto-Submit: Jake Macdonald <jakemac@google.com>
2024-02-14 00:03:35 +00:00
Paul Berry 0ae2ac1277 Language test of record demotion behavior.
When a local variable is promoted to a record type, and then an
assignment statement is used to assign a record literal to that local
variable, if the fields of the new record literal are not assignable
to the fields of the promoted record type, that's not a problem; both
the analyzer and front end agree that the local variable is simply
demoted.

But the spec implies that if the old and new record _shapes_ are the
same, then a compile-time error will occur instead of a demotion. I've
created https://github.com/dart-lang/language/pull/3613 to bring the
spec in line with the implementations. This test demonstrates the
current behavior of the implementations, and makes sure that it
doesn't regress.

Change-Id: I0eacd7ca7f6579a35dbc34687113a2112418f368
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/352462
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-02-13 23:28:19 +00:00