Commit graph

23007 commits

Author SHA1 Message Date
Jake Macdonald 5120fa3418 JSON macro, collections support
Note that this crashes in the CFE currently.

Also, in the analyzer, the diagnostics are being attached to the macro application and not the type annotation which is provided as a target.

Change-Id: Id5fc36eb862314015fd6839167f8ba043cd7d34e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349181
Reviewed-by: Morgan :) <davidmorgan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-31 00:02:58 +00:00
David Morgan 6b5580da62 [macros] Add language test for introspection cycle.
Small changes so it passes on the analyzer, the CFE does not yet detect cycles.

R=jakemac@google.com, scheglov@google.com

Change-Id: Iaeb586da7066e50b5b90c9793bc34b51e0eabbbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345062
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2024-01-30 13:08:44 +00:00
Daco Harkes f992bfc7b1 Revert "[vm/ffi] Introduce Struct.create and Union.create"
This reverts commit c2e15cff6d.

Reason for revert: https://github.com/dart-lang/sdk/issues/54754
Version skew somewhere in the analyzer/dartdoc/flutter combination.
We need to land the fix inside ffi_verifier.dart first, and then
reland the API docs that trigger the code path in the analyzer
that throws the exception.

Original change's description:
> [vm/ffi] Introduce `Struct.create` and `Union.create`
>
> Structs and unions can now be created from an existing typed data
> with the new `create` methods.
>
> The typed data argument to these `create` methods is optional. If
> the typed data argument is omitted, a new typed data of the right
> size will be allocated.
>
> Compound field reads and writes are unchecked. (These are
> TypedDataBase loads and stores, rather than TypedData loads and stores.
> And Pointers have no byte length.) Therefore the `create` method taking
> existing TypedData objects check whether the length in bytes it at
> least the size of the compound.
>
> TEST=pkg/analyzer/test/src/diagnostics/creation_of_struct_or_union_test.dart
> TEST=pkg/vm/testcases/transformations/ffi/struct_typed_data.dart
> TEST=tests/ffi/structs_typed_data_test.dart
> TEST=tests/ffi/vmspecific_static_checks_test.dart
>
> Closes: https://github.com/dart-lang/sdk/issues/45697
> Closes: https://github.com/dart-lang/sdk/issues/53418
>
> Change-Id: If12c56106c7ca56611bccfacbc1c680c2d4ce407
> CoreLibraryReviewExempt: FFI is a VM and WASM only feature.
> Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342763
> Commit-Queue: Daco Harkes <dacoharkes@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I285dc39946b5659219b37a1d8f10de479133957e
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/349061
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Zach Anderson <zra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-30 10:43:22 +00:00
Brian Quinlan af79f2fe22 [io] Fix a bug where Socket.addStream never completes after the socket is destroyed.
Bug:https://github.com/dart-lang/sdk/issues/54735
Change-Id: I8895ff6271eb1019ddad13c171f36cbec5fd84cd
TEST=tests/standalone/io/client_socket_destroy_and_add_stream_test.dart
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348764
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-01-29 23:09:22 +00:00
Daco Harkes c2e15cff6d [vm/ffi] Introduce Struct.create and Union.create
Structs and unions can now be created from an existing typed data
with the new `create` methods.

The typed data argument to these `create` methods is optional. If
the typed data argument is omitted, a new typed data of the right
size will be allocated.

Compound field reads and writes are unchecked. (These are
TypedDataBase loads and stores, rather than TypedData loads and stores.
And Pointers have no byte length.) Therefore the `create` method taking
existing TypedData objects check whether the length in bytes it at
least the size of the compound.

TEST=pkg/analyzer/test/src/diagnostics/creation_of_struct_or_union_test.dart
TEST=pkg/vm/testcases/transformations/ffi/struct_typed_data.dart
TEST=tests/ffi/structs_typed_data_test.dart
TEST=tests/ffi/vmspecific_static_checks_test.dart

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

Change-Id: If12c56106c7ca56611bccfacbc1c680c2d4ce407
CoreLibraryReviewExempt: FFI is a VM and WASM only feature.
Cq-Include-Trybots: luci.dart.try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/342763
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-01-27 09:28:40 +00:00
Nicholas Shahan e2f76a18f6 [test] Remove use of unwrapType() from test
This happened to work in both type systems because the property of the
same name exists in both, but technically `unwrapType()` is part of
the old type system and will be deleted soon.

Change-Id: I5620c5f409f0c6fe486b9a4c7a6872ee8deabc09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348800
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-01-26 23:56:11 +00:00
Alexander Aprelev 1d1531c8d9 [vm/io] Null-terminate scope-copied CStrings.
Fixes https://github.com/dart-lang/sdk/issues/54741
TEST=standalone/io/io_override_test

Change-Id: Ie907360dc4bcea05ef6fe3a5d4626e4e31399fc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348723
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2024-01-26 22:08:37 +00:00
Alexander Aprelev 34484719ca [io/ssl] Better error message when security context private key is missing.
Fixes https://github.com/dart-lang/sdk/issues/54719
TEST=standalone/io/security_context_no_private_key_test.dart

Change-Id: I6619b845a9cad8913efc00fc4f012bd87b27796a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348720
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
2024-01-26 20:49:09 +00:00
Srujan Gaddam 3b294fdab2 [dart:js_interop] Add isA helper
Closes https://github.com/dart-lang/sdk/issues/54138

Adds a helper to do better type-checks so that users don't
accidentally using is checks or have to manually do the right
typeof or instanceof checks. In order to do this, there is
some refactoring to make ExportCreator a SharedInteropTransformer
(as it's shared across all backends) so that we can reuse an
existing visitor. In the same class, we remove unnecessary setting
of parent pointers. We should clean up the fileOffsets as well,
but dart2js verifies that those are set, so we keep them as is
for now. Also adds some static errors for edge cases.

CoreLibraryReviewExempt: Helper for web-specific library.
Change-Id: I34d818ada1349b69afd15d170d3fafa0460f65fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347225
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-01-25 18:52:45 +00:00
Martin Kustermann 7b37838b6f [dart2wasm] Split --omit-type-checks into --omit-{implicit,explicit}-checks
This aligns the behavior of --omit-implicit-type-checks with dart2js

Change-Id: I453652339f23b89873d070422cf61eca77a2b68d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348164
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-01-25 09:52:25 +00:00
Srujan Gaddam f04e42be46 [dart:js_interop] Allow dart:html types in external signatures
Closes https://github.com/dart-lang/sdk/issues/54482

This is generally useful for users working around some limitations of
dart:html. While we want to encourage users to use package:web,
dart:html is not available on dart2wasm and users can use dart:html in
other ways already e.g. in an interop extension type, so it doesn't make
sense to disallow this. We also allow type parameters that extend these
types as well.

In order to make this a bit more performant (subtyping checks may be
expensive), code is refactored to cache more readily and separate the
notion of an allowed representation type vs interop extension type. We
also define the notion of a "core" interop type, which will be useful
when we want to efficiently query what interop type users are using
underneath the possible layers of extension types.

A few missing tests around typed_data are added and the error around
invalid types is reworded to include this change and be more consise.

Change-Id: I256b0cce4355d2a21853b0c5bf641166cafc523e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347224
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2024-01-25 02:10:44 +00:00
Paul Berry 872ef163f1 Fix missing analyzer error when pattern for-in iterable is nullable.
This was a mistake in the shared logic implementation during the
implementation of patterns; instead of verifying that the for-in
expression is a subtype of `Iterable<dynamic>` (or `Stream<dynamic>`
in the case of an `await for`), it merely verifies that it's a subtype
of `Iterable<dynamic>?` (or `Stream<dynamic>?`). At some point, the
requisite error checking was added to the front end, but not to the
analyzer.

In an ideal world, the solution would be to remove the error check
from the front end and add it to the shared logic; however, doing so
is not easy, because what needs to be done is an assignability check
(as well as insertion of implicit downcasts and other coercions). The
shared logic doesn't currently have a good hook for doing that. So,
for now, this CL simply adds the requisite check to the analyzer. I
plan to try to find a clean way to share some of this logic in a
follow-up CL.

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

Change-Id: Ib2fa8bce758dfe12401d85850666674ca1317e3f
Bug: https://github.com/dart-lang/sdk/issues/54671
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347360
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-01-24 22:23:09 +00:00
MarkZ 8edbcacfb0 [ddc] Removing some references to "legacy" DDC modules.
"DDC" is now the accepted name for the module system.

Change-Id: I655219ccc7cff7ff99b1311518ef6ed6e7d1b2a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348085
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-01-24 21:22:25 +00:00
Paul Berry 97edad1568 Flow analysis: Use extension type erasure for implicit is reachability.
Whenever a pattern performs an implicit `is` test, flow analysis
attempts to determine whether the `is` test is guaranteed to succeed;
if it is, then flow analysis considers the code path in which the `is`
test fails to be unreachable. This allows flow analysis to recognize
switch statements that are trivially exhaustive (because one of the
cases is guaranteed to match), avoiding spurious errors such as
"variable must be assigned before use" or "missing return statement".

This change upgrades the logic for computing when an `is` test is
guaranteed to succeed, so that it accounts for type erasure of
extension types. This brings flow analysis's treatment of switch
statements into closer alignment with the exhaustiveness checker,
which should reduce the risk of confusing error messages. For more
information see
https://github.com/dart-lang/language/issues/3534#issuecomment-1885839268.

Fixes https://github.com/dart-lang/language/issues/3534.

Bug: https://github.com/dart-lang/language/issues/3534
Change-Id: Ib73d191e04e7fa8c0e6888c2733dae73d8f389da
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345822
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-01-24 15:23:27 +00:00
Martin Kustermann 7f668b63c3 [dart2wasm] Introduce a --minify flag to dart2wasm that uses "minified:Class<cid>" for class names
The `minified:...` encoding of class names mirrors the one used by
dart2js. So the added test will work in both modes.

This reduces optimized dart2wasm output

* hello world by 20%
* flute complex by 8.5%

Change-Id: I080de40919ee3f25f0f0d8c9b82aa662f7e734aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347741
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-01-24 09:10:15 +00:00
Srujan Gaddam a6e8759888 [dart2wasm] Add concrete box and symbol for JSBoxedDartObject
The current implementation externalizes and internalizes the Dart
value instead of adding a box and using a runtime-specific symbol.
This makes the implementation consistent with the JS backends.

Change-Id: Iefa382f742bc819b18dfe27ca33741b12473ee39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347222
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-01-23 23:39:49 +00:00
Mayank Patke b4be031505 [dart2js] Ensure SSA builder doesn't omit casts with SNS checks enabled
Change-Id: I108e73e45e98047b45e3f904fe7b93acc5dd2221
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/348040
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-01-23 23:22:51 +00:00
Mayank Patke e78c0cf7a0 Remove language tests that opt out of null safety
Change-Id: I17409423f04f2eddebd4f20fd613cbcc9164dca5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347860
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-01-23 18:23:32 +00:00
Johnni Winther 694c2911e2 [cfe] Support json_serializable macro
This refactors and update the cfe macro implementation to support
macro annotations generated by macros.

Change-Id: I6a4b669f2f01b1f2fec4efbc87271eecf397205d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346841
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-01-23 12:24:49 +00:00
Mayank Patke f79ed9301b [dart2js] Remove remaining language version overrides
Now that dart2js only takes migrated files as input, all tests should
use the current language version.

Change-Id: I6c84850f5786aeac04154b67bd7a3c19083c8bba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345344
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2024-01-23 01:26:09 +00:00
Nicholas Shahan b811ab5b04 [ddc] Reset all initialized consts on hot restart
Clear local caches storing const values in each module.

Change-Id: I7766e92df6b8d1f91bad5fbb2addb8ace7763646
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347220
Reviewed-by: Mark Zhou <markzipan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-01-22 23:25:18 +00:00
Sigmund Cherem 05a53dae0d [tests] delete html/async_test.
This test was written to validate correctness of the web
implementation of `dart:isolates`, back when it was supported.

Today, this API is unsupported in both dart2js and DDC. The test was
consistently failing in DDC and skipped in dart2js. We don't believe
it's valuable to continue running this test at this moment.

Change-Id: I578533b09c4172daf3f49fcc528ccb2cebebb53d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347642
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2024-01-22 18:54:04 +00:00
Jake Macdonald 8c537438ec JSON macro: support extending serializable classes
Change-Id: I157d71225a6170fdfb6bc56da4eb1b8581fe3d5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347400
Commit-Queue: Jake Macdonald <jakemac@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
2024-01-22 17:48:27 +00:00
Oleh Prypin 5a1ef6089c Revert "[ffi]: Remove pointer elementAt method."
This reverts commit f706ff4ee2.

Reason for revert: b/321667799 - package:win32 uses this method - a78ff108fb/lib/src/com/iapplicationactivationmanager.dart (L46)

Original change's description:
> [ffi]: Remove pointer elementAt method.
>
> Closes #54250
>
> TEST=test/ffi
>
> R=dacoharkes@google.com
> Change-Id: I0e88adfcfe3caef0ad3bb6814ad8f27dce5dc7f4
> CoreLibraryReviewExempt: FFI only
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346380
> Reviewed-by: Daco Harkes <dacoharkes@google.com>
> Commit-Queue: Martin Kustermann <kustermann@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>
> Auto-Submit: Shikhar <shikharish05@gmail.com>

Change-Id: I1b7a48d14e9b85676a27f76a926e21cac9c76c85
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347600
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-01-22 12:20:48 +00:00
Shikhar Soni f706ff4ee2 [ffi]: Remove pointer elementAt method.
Closes #54250

TEST=test/ffi

R=dacoharkes@google.com
Change-Id: I0e88adfcfe3caef0ad3bb6814ad8f27dce5dc7f4
CoreLibraryReviewExempt: FFI only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346380
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Auto-Submit: Shikhar <shikharish05@gmail.com>
2024-01-22 11:34:18 +00:00
Brian Quinlan e5f53ce005 [io] Add tests for failure to resolve a path using FileSystemEntity.resolveSymbolicLinks.
Bug:https://github.com/dart-lang/sdk/issues/53862
Change-Id: I269668064657856f2c2aa3479618b206aad075aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/347204
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-01-19 01:47:49 +00:00
David Morgan b28ced8e93 [macros] Add language test: applying a macro in the wrong place is an error.
Change-Id: Iebdc005d792ac2e2fca912f792d3caf16810bb32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346044
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Morgan :) <davidmorgan@google.com>
2024-01-18 09:02:52 +00:00
Alexander Markov 5230995e3a [vm] Fix unwinding records on Windows
This change fixes the following 2 bugs related to unwinding records
on Windows:

1) When cross-compiling from another OS to Windows, unwinding records
   were not added to the end of the code section. Later, when loading
   AOT snapshot, arbitrary bytes at the end of the code section were
   used as the unwinding data, which could result in the errors
   returned from Windows API calls.

2) When code section is mapped, its size was rounded up to the page
   size; when looking for unwinding record, size of the unwinding
   record was subtracted from the rounded size. This is not correct
   as unwinding record is placed right at the end of code section,
   so code section size should be used before rounding.

Also, magic value is added to the unwinding record in order to
verify that it is preserved and correctly found.

TEST=Manually tested repro from b/320642692
TEST=ffi/ffi_induce_a_crash_test

Fixes b/320642692
Fixes https://github.com/dart-lang/sdk/issues/54206

Change-Id: Id0c6413cd1b759da9e9f25f7617eef55f33b04a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346940
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-01-18 01:09:49 +00:00
Paul Berry c5fb584a75 Language test pattern type schemas.
I discovered recently that when we implemented the "patterns" feature,
we got the pattern type schema for cast patterns wrong--it was
specified to be `_`, but what was actually implemented was
`Object?`. I've filed a breaking change request to address that:
https://github.com/dart-lang/sdk/issues/54640.

In the course of prototyping a fix, I was surprised to find that no
language tests or co19 tests were affected; it appears that we don't
have adequate test coverage of pattern type schemas. This CL addresses
the lack of test coverage by adding a language test.

The test case for cast patterns is currently commented out, pending
resolution of the breaking change request; after the breaking change
lands, I will update the test accordingly.

Change-Id: I0d27fd8ac65f16d21a8597586e6f76fd9a5ba86e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346621
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2024-01-17 21:55:14 +00:00
asiva 93f41eccf0 [VM/test] Skips test on Android as executable bit is not set for shell script.
TEST=fixes test.

Change-Id: I384aa695b3072c31dbd120cae17504a373a22275
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345861
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-01-17 19:21:19 +00:00
Daco Harkes 964e983f15 [vm/ffi] Initialize Library::ffi_native_resolver_ on deserializing snapshots
TEST=tests/ffi/native_assets/asset_process_test.dart

Closes: https://github.com/dart-lang/sdk/issues/54607
Change-Id: Id4e787a66f18db98473008b7da690dd2ca79a88e
Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-kernel-precomp-linux-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346321
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-01-16 11:58:48 +00:00
Johnni Winther 70d3adade2 [cfe] Move hoisted variables after variable caches
This moves the hoisted declaration of pattern variables till after the
variable cache declarations, such that any use of variables in the
matched expression, shadowed by the pattern variables, occurs before the
declaration of the shadowing variables.

Closes #54559

Change-Id: Id8ca8e7a499b9d71a50cd9987808d159f26bbd24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345942
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-01-16 09:09:29 +00:00
Paul Berry 973eca72f5 Fix handling of extension types in relational patterns.
In https://dart-review.googlesource.com/c/sdk/+/345082, type erasure
was added to the handling of relational patterns, to address some co19
failures, e.g.:

    extension type const BoolET1(bool _) {}
    const True1 = BoolET1(true);
    String testStatement1(bool b) {
      switch (b) {
        case == True1:
	  ...
      }
    }

This was failing because the type of `True1` (`BoolET1`) is not
assignable to the argument type of `operator==`, which is
`Object`. (This is because extension types do not, by default, extend
`Object`; they extend `Object?`).

Adding type erasure elimited the co19 failure, but it caused other
code to be allowed that shouldn't be allowed, such as:

    extension type const E(int representation) implements Object {}
    class A {
      bool operator <(int other) => ...;
    }
    const E0 = E(0);
    test(A a) {
      if (a case < E0) ...;
    }

This shouldn't be allowed because the type expected by `A.<` is `int`;
allowing `E0` to be passed to this operator breaks extension type
encapsulation.

The correct fix is for assignability checks for `operator==` to use
`S?` rather than `S`, where `S` is the argument type of
`operator==`. This is consistent with the patterns specification, and
it ensures that `== null` and `!= null` are allowed, while continuing
to prohibit relational patterns that break extension type
encapsulation.

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

Bug: https://github.com/dart-lang/sdk/issues/54594.
Change-Id: Id090f432500d75ba694383f1788d58353cd1fc72
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345860
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2024-01-12 19:31:40 +00:00
Jake Macdonald d2e490782c add json serializable macro as a language test
Change-Id: Ifabcad0acc361abcba9af20568acc19bd872ddb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345760
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Morgan :) <davidmorgan@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2024-01-12 16:47:21 +00:00
Sergey G. Grekhov f02b05630a [co19] Roll co19 to b5126f0bd51ea0819df8d5c362574f951a564940
2024-01-12 sgrekhov22@gmail.com Fixes dart-lang/co19#2480. Fix typos, add issue numbers (dart-lang/co19#2481)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2477. Rename and reorder existing constants tests for match operators before adding new ones (dart-lang/co19#2478)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2420. Add null-check-pattern tests for extension types (dart-lang/co19#2475)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2119. Add missing experimental flags (dart-lang/co19#2474)
2024-01-10 sgrekhov22@gmail.com dart-lang/co19#2119. Fix typo and improve error messages in Timer tests (dart-lang/co19#2473)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2471. Fix timer constructor tests. Add check for microtasks (dart-lang/co19#2472)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2428. Add `call` member tests for extension types (dart-lang/co19#2438)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2449. Update positions of analyzer expected errors (dart-lang/co19#2450)
2024-01-09 sgrekhov22@gmail.com Fixes dart-lang/co19#2440. Add asyncStart/End() to Stream interface tests (dart-lang/co19#2457)
2024-01-09 sgrekhov22@gmail.com dart-lang/co19#2420. Add another variable pattern exhaustiveness test (dart-lang/co19#2469)
2024-01-08 sgrekhov22@gmail.com dart-lang/co19#2420. Add constant pattern exhaustiveness tests (dart-lang/co19#2467)
2024-01-08 sgrekhov22@gmail.com dart-lang/co19#2436. Add expected constant evaluation error for CFE (dart-lang/co19#2470)
2024-01-08 sgrekhov22@gmail.com dart-lang/co19#2420. Add null-assert pattern exhaustiveness tests (dart-lang/co19#2468)
2024-01-05 sgrekhov22@gmail.com dart-lang/co19#2420. Add parenthesized pattern exhaustiveness tests (dart-lang/co19#2464)

Change-Id: I86862732cca7c042120bf312403279c2cc10c135
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345960
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-01-12 11:23:39 +00:00
Daco Harkes ac5e3d38c3 [vm/ffi] Introduce SizedNativeType
Both `sizeOf` and `AllocatorAlloc.call` use the new type as bound.
This prevents runtime errors on trying to call these two static
methods with unsized native types. All tests testing for these runtime
errors have been deleted.

The `NativeTypes` implementing `SizedNativeType` are as follows:
* The native integer types, `Float`, and `Double`.
* `AbiSpecificInteger` and it's subtypes.
* `Struct` and `Union` and their subtypes. The

The `NativeTypes` not implementing `SizedNativeType` are as follows:
* `Void` has no size.
* `Opaque` and subtypes have unknown size.
* `Handle` is considered opaque. Cannot be used as field in compounds.
* `Array` does not carry a size in its type. Can be used as fields in
  compounds with an annotation specifying the size.
* `NativeFunction` is considered opaque. Would have variable size.
* `VarArgs` is only a marker in function signatures.

`Struct`s and `Union`s can have only `SizedNativeType`s and `Array`s
as fields. Documentation for these is in flux in another CL, so we
should update it there.

This CL also replaces a bunch of `extends NativeType` with
`implements` clauses and made `NativeType` itself `abstract`.

TEST=Dart SDK build
TEST=ffi test suite

Bug: https://github.com/dart-lang/sdk/issues/54542
CoreLibraryReviewExempt: VM and dart2wasm feature only.
Change-Id: Ib4f6b58f7204bd063ace20133162798d8c9483e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345221
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-01-12 10:13:39 +00:00
Nicholas Shahan 1572bb563f [ddc] Delete typeRep() and legacyTypeRep()
Replaces all uses with the equivalent `TYPE_REF()` and 
`LEGACY_TYPE_REF()` because they are used in the shared dart:_rti 
library and there is no need to support both.

Change-Id: I8c04eb12856cf6933a168f3e63351a45cd5d704e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344608
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2024-01-12 00:45:47 +00:00
asiva e518b8c3be [VM/Runtime] - Do not try to resolve exec path for default namespace
TEST=new test added
Bug:54516
Change-Id: I67b1fe7ee07db342d328e5272ddca5411fd5df28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345320
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2024-01-11 19:12:52 +00:00
Parker Lougheed e36cca289f [vm/compiler] Expand inlining and const propagation of double.isNegative
TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-release-arm64-try,vm-aot-linux-product-x64-try,vm-aot-linux-debug-simarm_x64-try,vm-linux-debug-ia32-try,vm-linux-debug-simriscv64-try
Change-Id: I586c678ddd69a3e5c1b8ddf97ae3fc781662d192
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344080
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-01-11 12:20:56 +00:00
Aravind 8945d1be75 [io] Changed Minimum Limit for Trimming File or Dir Path in Windows
Closes https://github.com/dart-lang/sdk/pull/54536

GitOrigin-RevId: 9d8b1eafac9a6ff88f5277826dff1e51236b661c
Change-Id: Id65f5778a4173be3d253398c0c030d322c1b42df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345201
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-01-11 10:53:09 +00:00
Nicholas Shahan 154cf8c52b [tests] Cleanup remnants of multi-test migration
- Rename some compile time errors tests to end with "error_test.dart"
- Delete runtime tests that no longer perform the operations they
  claim to be testing. In many cases they do nothing at all.

Change-Id: I49c7b50d6628f56641b878635b32dbc0bc016bbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345345
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2024-01-10 18:35:50 +00:00
Vyacheslav Egorov 3e0ae6da5f [vm] Remove dual mapping of code
We are no longer using Dart VM in a setting where this
matters as a security measure and it just complicates
portability for no benefit.

There is an indication that it is causing problems when
running Linux build of Dart VM under Docker on Mac OS X.

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

TEST=ci

Cq-Include-Trybots: luci.dart.try:vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try
Change-Id: I11bdaa8faebaca1df6fd59097049bdaea9cb8e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344581
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2024-01-09 12:36:55 +00:00
Nate Biggs ef75007c2f [dart2js] Fix as-check type registration.
We would expect failing as checks to throw in all modes (unless --omit-as-casts is provided). However, the new test program fails in production mode. This is because we are not registering the type usage of the function's type parameter. This leads us to drop the as check completely later on.

We should be doing subtype checks with nullability if we want to consider an as test omitted.

Golem patch results: https://golem.corp.goog/Comparison?repository=dart#targetA%3Ddart2js%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D107840%3BpatchA%3Dnatebiggs--dart2js--Fix-as-check-type-registration.-7%3BtargetB%3Ddart2js%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D107839%3BpatchB%3DNone

Fixed: https://github.com/dart-lang/sdk/issues/54419
Change-Id: If93f78a939a690f05f5398c1a5ca971df1fc9243
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343821
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-01-09 00:04:50 +00:00
Nate Biggs 5229eabddf Update tests to pass in web/production mode.
Change-Id: Ibea6022fcdd0eff53c6be9a5f7c0eeb0fbf20635
CoreLibraryReviewExempt: Updating tests to pass for web production backend.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343822
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2024-01-08 17:21:29 +00:00
Chloe Stefantsova 04e8677d59 [cfe] Infer mixins by directly solving for equality
The direct algorithm for solving for equality replaces the more
general constraint solving algorithm. It reduces complexity and
removes the requirement on the constraint gathering and solving engine
to be applicable at the earlier stages of compilation.

Change-Id: I73dfa39bb1534803c6985578708ecab198c26e25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343920
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-01-08 11:42:39 +00:00
David Morgan 5cb4351c76 [macros] Fix class definition augmentation test.
Resolve constructors, fields and methods correctly.

Tweaks to test and support code so they're closer to passing.

R=jakemac@google.com, scheglov@google.com

Bug: https://github.com/dart-lang/sdk/issues/54404
Change-Id: I5ccd5e0c3843dc32fb7838a4bc78b65f982f3ce9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/343161
Commit-Queue: Morgan :) <davidmorgan@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Morgan :) <davidmorgan@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-01-08 08:14:58 +00:00
Stephen Adams 7933cd741d [dart2js] Prevent type expressions being hoisted above guards
Use a pinned HTypeKnown on the receiver of the HInstanceEnvironment to
pin the type expression. When the the receiver has a wider type that
is legal for the type expression, this keeps the type expression at a
location where it is valid. Type expressions can still be hoisted if
the HTypeKnown is redundant and optimized away.

Bug: #54329
Change-Id: Iae378f9d517e3e22deca198195cad9811cf37772
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/344841
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2024-01-05 19:03:29 +00:00
Daco Harkes ce1af47fa9 [vm/ffi] Check Array<T extends AbiSpecificInt> bounds [] and []=
TEST=tests/ffi/inline_array_test.dart

Closes: https://github.com/dart-lang/sdk/issues/54379
Change-Id: I89a637dce0af9520d29d18ec595d868cd0b1604c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345061
Reviewed-by: Tess Strickland <sstrickl@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2024-01-05 12:35:49 +00:00
Daco Harkes cd9eaef675 [vm/ffi] Check Array<T extends Struct> bounds on []
TEST=tests/ffi/inline_array_test.dart

Bug: https://github.com/dart-lang/sdk/issues/54379
Change-Id: I2799056ce48fa8cfa590512b241fe72f61a07dbf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345060
Reviewed-by: Tess Strickland <sstrickl@google.com>
2024-01-05 12:35:49 +00:00
Daco Harkes d4f8f24dc8 [vm/ffi] Array fixes
`_checkIndex` was returning dynamic.

And it was missing for `PointerArray`.
Bug: https://github.com/dart-lang/sdk/issues/54379

TEST=tests/ffi/inline_array_test.dart

Change-Id: I148545e50463e89fb3a884757ef92444addefc61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/345000
Reviewed-by: Tess Strickland <sstrickl@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2024-01-05 12:35:49 +00:00