Commit graph

998 commits

Author SHA1 Message Date
Lasse R.H. Nielsen 06d6ef38a9 Fix bug in Uri.resolve with IPv6 addresses.
The `resolve`/`resolveUri` operation would take the
`.host` of the URI reference and include it verbatim
in the output. Since the `.host` getter returns IPv6
addresses *without* their `[`...`]` braces, that would
become invalid.

Also make sure to normalize the parts of the URI reference
that are used, if it is not a platform URI.

Fixes #55085

BUG= https://dartbug.com/55085

Change-Id: I3dbc8af953af0974346e38ba3203796647069ea8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/355781
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
2024-03-11 14:48:24 +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
Ö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
Lasse R.H. Nielsen 64b03d1998 Add extra documentation to Enum to point to EnumName.
Closes https://github.com/dart-lang/sdk/pull/53164

GitOrigin-RevId: 0c96101a1239a4e3a04cd01c4765e5687c39dc0f
Change-Id: I26391dddde87cdea0cc6ae4a70d04be1a48576f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319463
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2024-01-23 09:34:32 +00:00
Ömer Sinan Ağacan 7cceaebd49 [dart2wasm] Start using WebAssembly.String imports
Refactor `JSStringImpl` to use the js-string-builtins API[1].

When the module `WebAssembly.String` is not available we define a
"polyfill" with the previous imports, so this change is backwards
compatible.

Also updates some of the methods to use avoid multiple `this.length`
calls (which do an FFI call), and use unchecked getters when possible.

A new library `dart:_error_utils` is introduced for faster range and
index checks when the length (or max value) is known to be positive
(e.g. when it's the length of a string).

For now only `JSStringImpl` and `operator []` and `operator []=` of
`JSArrayImpl` are updated to use the new range and index checks. Rest of
the libraries will be updated separately.

[1]: https://github.com/WebAssembly/js-string-builtins

CoreLibraryReviewExempt: dart2wasm specific library change.
Change-Id: I9436def0cfe59c631f6f4e15ea06cc18a47a738e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/335043
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2023-12-08 10:04:41 +00:00
Lasse R.H. Nielsen a1783a9c34 String.fromCharCodes allows start and end after end of iterable.
The current `String.fromCharCodes` behavior, throwing if `start`
or `end` is larger than the length of the `charCodes` iterable,
is inconsistent with the argument being an `Iterable<int>`,
which the user is not expected to know the length of.

Most other operations that accepts or produces an `Iterable` and
restricts it to a range, will allow the range to exceed the length
of the iterable, acting like `.take(end).skip(start)`, just without
needing to create wrappers that hide the original value.

(`List.setRange` is another exception, and should probably be fixed
by allowing the range to be partially filled, since it's too hard
to change it to require a `List` argument.)

Fixes #50253, #53937

Tested: Added to `corelib/string_fromcharcodes_test.dart`
Bug: https://dartbug.com/53937, https://dartbug.com/50253, https://dartbug.com/23282
Change-Id: Ie19c5fa8e715ea1c58c9c77c247f2a563654c1aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/333921
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2023-11-17 13:34:22 +00:00
Lasse R.H. Nielsen 0234a8f17f Fix bad link in updated docs.
CoreLibraryReviewExempt: Comment only.
Change-Id: Ibaec3812e430ba0c8644315fba062bca62f3c173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331241
Auto-Submit: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2023-10-20 14:47:26 +00:00
Lasse R.H. Nielsen 0ecb9ba545 Update documentation on fromEnvironment constructors.
CoreLibraryReviewExempt: Comments only.
Change-Id: If2e080764bc98ee6cb7fe31dffe12c66144c7352
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/331182
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-10-20 07:57:18 +00:00
Brian Quinlan b04c5a433e Adds tests and documentation for print line ending behavior
Bug:https://github.com/dart-lang/sdk/issues/53161
Change-Id: I3f13af3cb852b3656341922b9656ec91fc413eed
Tested: documentation + unit test only
CoreLibraryReviewExempt: Only adds documentation and adds a unit test to verify existing behavior
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/323426
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-10-17 22:10:38 +00:00
Sam Rawlins 1b4ae5a7e1 Refer to unnamed constructors in doc comments with '.new'
Cleanup for https://github.com/dart-lang/dartdoc/issues/3531

This makes these comment references more idiomatic, I think
more readable, and supports dropping the leading `new ` syntax
in doc comments.

Change-Id: Id832ad14d9ea08fe03fe3125065755f49b1b93ed
CoreLibraryReviewExempt: doc comment only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/330683
Reviewed-by: Devon Carew <devoncarew@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2023-10-17 14:42:38 +00:00
Stephen Adams 8ea74c0f2e [js_runtime] Use URLSearchParams to escape query parameters
Use URLSearchParams to escape query parameters.

- For large query parameters (>100KB), where escaping the parameters causes jank, this can be 2x-5x faster, reducing ~100ms pauses to nearer frame rate.

- For small query parameters (<100B) it can be slightly (10-20%) slower, but still well below 1 millisecond.


TEST=ci

Issue: #53712

Change-Id: I045bac7a067a658a58aaac4266409d526ccda774
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/329822
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-10-13 16:36:47 +00:00
Nicholas Shahan e7073bfd0f [core] Avoid implicit downcast from dynamic
Add a static type to the variable declaration so it isn't inferred
as dynamic causing multiple implicit downcasts downstream.

CoreLibraryReviewExempt: Trivial change.
Change-Id: Ibef1d4666f5a6a5bbab363195c4b4dea66e8eac3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/328741
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-10-02 23:33:19 +00:00
Lasse R.H. Nielsen c15f054809 Hide the existence of EfficientLengthIterable better.
The `EfficientLengthIterable` is an internal marker interface
that allows the SDK to more efficiently check, effectively,
`v is List || v is Set || v is Queue`, and some other
known internal types, which allows it to assume that `.length`
is efficient and doesn't iterate the iterable.

It's not intended for external use, but the current design
both has the name mentioned specifically in the declaration
of the public types `List`, `Set` and `Queue`,
and possibly allows the type to leak through the
least-upper-bound algorithm.

This change moves the mention of `EfficientLengthIterable`
from the public types to an anonymously named private type,
and ensures that the private type is never the result of
a least-upper-bound computation, by adding another
interface with the same depth that all the public
types implementing `EfficientLengthIterable` also implement.

(A longer term solution to `EfficientLengthIterable` looking
like it's a public name could be combining the collection-
related code from `dart:collection`, `dart:core` and
`dart:_internal` into a single `dart:_collection_impl`,
and exporting the relevant types from there. Then
we could make the interface be `_EfficientLengthIterable`
again.)

Change-Id: I717743f0ca253782162be0ad9ff05036fdf57159
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322320
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-09-12 11:08:42 +00:00
Hrishikesh Kadam 651a9ba155 Remove duplicate doc in Uri.encodeQueryComponent()
Closes https://github.com/dart-lang/sdk/pull/53125

GitOrigin-RevId: 74acce42f4b4a9cbdea63e4576b58f1d3209ea76
Change-Id: Id1a72303cd877d106ee8b86a1b8572b3f21ebc29
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318300
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-08-08 18:11:51 +00:00
pq 4e6ed304f1 fix @override description typo
Change-Id: I52df1ae27774ce1880c3ef2f53dbb5335a4cda01
CoreLibraryReviewExempt: typo fix (no semantic changes)
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/318780
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
2023-08-07 17:00:48 +00:00
Parker Lougheed 99745598cd Update old linter site links to dart.dev
Bug: https://github.com/dart-lang/linter/issues/4460 and https://github.com/dart-lang/site-www/issues/4499
Change-Id: Ieb90512aac4e476b922765c6ee191085a2ad2c9b
CoreLibraryReviewExempt: Only updates a link in documentation comments.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311880
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2023-08-04 19:45:23 +00:00
Amir Panahandeh 6dfcd40684 Fix wrong example for queryParametersAll
Closes https://github.com/dart-lang/sdk/pull/53083

GitOrigin-RevId: 49d4b6666e901ecf5e5569532d9b8d19f057f2d4
Change-Id: Ie246ac593cae8638f2d4f5cc6950e426e4b74237
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317301
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-08-01 08:27:58 +00:00
Graciliano Monteiro Passos ab2fe4f5e2 Document the return value of any and every for empty values.
Closes https://github.com/dart-lang/sdk/pull/52847

GitOrigin-RevId: f5382101762582c7d865833e42d9af39fc0a6131
Change-Id: Iafeb53a7e583e0309d08d9dffe3803b7f772b70d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312380
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-07-11 13:05:40 +00:00
M. Javad Pourqavam a0392698bf Fix docs of DateTime.from constructors
Closes https://github.com/dart-lang/sdk/pull/52866

GitOrigin-RevId: bbc99c5f36dde2e53cc68aa3d8a5acfd5dd0fbb2
Change-Id: I9a5cf4b2a9d67fc3567af0f839272a104bf9edc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/312760
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-07-11 10:03:48 +00:00
Nate Bosch 1837435273 Mention iteration depth for some Iterable methods
Closes #7797

Most of the other suggestions have already been added, add an explicit
mention of shorcutting for `contains`, `firstWhere`, and `single`,

R=lrn@google.com

Change-Id: I53c254839f198a368fcb8734c3f7983b9b3ccad4
CoreLibraryReviewExempt: Doc changes only.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310767
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2023-06-22 20:44:09 +00:00
Simon Binder 62488db4da [vm/ffi] Add DynamicLibrary.close()
This adds the `close()` method to `DynamicLibrary`, which uses
`dlclose()` on Unix and `FreeLibrary` on Windows to close a dynamic FFI
library.

TEST=tests/ffi/dylib_close_test.dart
Closes https://github.com/dart-lang/sdk/issues/40159

Cq-Include-Trybots: luci.dart.try:vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-riscv64-try,vm-ffi-qemu-linux-release-arm-try,dart2wasm-linux-d8-try,dart2wasm-linux-chrome-try,vm-reload-rollback-linux-debug-x64-try,vm-reload-linux-debug-x64-try,vm-win-debug-x64c-try,vm-win-debug-x64-try,vm-aot-android-release-arm_x64-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-asan-linux-release-x64-try,vm-aot-msan-linux-release-x64-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-x64-try,vm-aot-mac-release-arm64-try,vm-aot-win-debug-x64c-try,vm-aot-win-release-x64-try
CoreLibraryReviewExempt: `dart:ffi` VM only API.
Change-Id: I73af98677b481902fe548bdcee56964a0195faf0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307680
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-06-15 17:19:37 +00:00
Johnni Winther e831cb8510 [cfe] Check @patch annotations
This normalizes the checking of patches so that it matches the checking
of augmentations. This means that the @patch annotation must and can
only be used on patches.

The dart: libraries and patches have been updated accordingly.

TEST=ffi

Change-Id: I78767eebd1a8861859067ae5ff9c0339f0985bb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306041
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-06-13 07:27:08 +00:00
David MARKEY a731af1703 Annotate DateTime.timestamp() with Since("3.0").
Closes https://github.com/dart-lang/sdk/pull/52638

GitOrigin-RevId: ea045c0aa761981613f6d8e36eeeb389c8224053
Change-Id: Idc601b6a8069f2ed504df646862faf412de9a1b6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308020
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-06-08 11:06:49 +00:00
Brian Quinlan 95509b2b34 Add tests to ensure that \n is not translated to the platform line ending and document that behavior.
Change-Id: I52668a87507dfdc560fd7c1ec20e86114c1199b7
CoreLibraryReviewExempt: documentation and test-only change
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303421
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-05-24 18:50:29 +00:00
mnordine 2369a3be0f Fix bool.parse() examples
Closes https://github.com/dart-lang/sdk/pull/52389

GitOrigin-RevId: 4987894e85a28e18b183eb45a111d47444d305db
Change-Id: Ib68581d7966c0fb24ccd9070054ea9aaadd2e17d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303221
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-05-16 11:16:16 +00:00
Lasse R.H. Nielsen a826699931 Have Uri give better error message for invalid Windows path.
CoreLibraryReviewExempt: Trivial change to error path.
Change-Id: Iadfb80eeb1e6c58686ed9741a88f369e130ed9e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302780
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
2023-05-11 16:43:28 +00:00
Nicholas Shahan a7854364a6 [docs] Fix small typo in code example for Function
Change-Id: Ia762b823c51724229c0eb452a02885ff0f8bc7af
CoreLibraryReviewExempt: Changes documentation only.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299140
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Auto-Submit: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-04-27 17:07:38 +00:00
Lasse R.H. Nielsen 3e0ca136b6 Update documentation on Record and identical.
Smaller clean-ups.

CoreLibraryReviewExempt: Documentation only.
Change-Id: Idfe543f18927043ae8ec73e81dc7d9d333bb88df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294542
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-13 12:35:44 +00:00
Lasse R.H. Nielsen 2a38b22aed Add a few more class modifiers.
Mostly interface on classes that can't be extended anyway.
A few `final` implementation classes.

Tested: No new functionality, only restrictions.
CoreLibraryReviewExempt: Just modifiers.
Change-Id: I1f298fe43836892c94c0b23326fda37b1904ec6a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293683
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-07 21:54:44 +00:00
Lasse R.H. Nielsen 87ccb4012c Use padLeft in Duration.toString.
Optimizing to avoid allocations probably not worth the cost in code size
and start-up time required by the constant list.

CoreLibraryReviewExempt: Minor change to internal implementation.
Change-Id: Ib54bf75f15aa096ac8e07577a47590f3cd9d55dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292780
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-05 06:24:20 +00:00
Lasse R.H. Nielsen 511bf8a80f Add nonNulls, indexed and other extensions on iterables.
Also adds `firstOrNull`, `lastOrNull`, `singleOrNull`, and `elementAtOrNull`.

I chose `nonNulls` instead of `whereNotNull()`.
The latter should have been a getter, but isn't.
Making it a getter in the platform libraries would be confusing,
and make migrating from `package:collection`'s function harder,
so instead I gave it a completely new name.
The alternative would be to retain the non-idiomatic `whereNotNull()`
for familiarity. But then it would be tool late to fix.



Fixes #49928

BUG= https://github.com/dart-lang/sdk/issues/49928

CoreLibraryReviewExempt: Everybody's on vacation, everybody everywhere.
Change-Id: If464e3bd6bc97cbeefc3e5084b4cbaadac3f1e95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290760
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-04 23:05:54 +00:00
Lasse R.H. Nielsen 5573ce7b84 Make Iterable be the default implementation of itself.
Makes `Iterable` a mixin class with a `const` constructor,
and `IterableBase` and `IterableMixin` (to-be-deprecated) aliases
for it.

Combining everything in one place avoids (some) code
duplication.

Also gave the methods a quick overhaul for formatting,
removing uses of `late` and unnecessary element accesses,
and some general tweaks.

CoreLibraryReviewExempt: Refactoring of redundant types.
Tested: Refactoring. If existing tests work, it works.
Change-Id: Ie49a88f713d386d2d118c53606a71bdd50e1eb11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287600
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-04 21:45:19 +00:00
Lasse R.H. Nielsen f51e9d1dda Make RegExpMatch.pattern have type RegExp.
It's always a RegExp, so it's a safe change.
It's also a very, very rarely used property,
since nobody ever noticed that it wasn't typed optimally.

Tested: Type change of getter to actual type of value. No new test.
CoreLibraryReviewExempt: Aske is out.
Change-Id: Ifb560a80c3cdb05be0164c593383539dc10ec0dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267961
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-04-04 20:34:36 +00:00
Lasse R.H. Nielsen 2f7213342b Add record-related wait extensions on Future tuples.
With the addition of records, it now makes sense to create an API
for parallelizing of futures of different types, like `Future.wait`
does for collections of same-typed futures.

The `wait` getters here apply to tuples of 2-9 futures of distinct types, which should be enough for most reasonable uses.

Planned addition for Dart 3.0.



CoreLibraryReviewExempt: Everybody's on vacation, everybody everywhere.
Change-Id: Iaa814e02e2274082bb8a29b9a18b4930bcc953bb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288903
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-04 11:39:49 +00:00
Lasse R.H. Nielsen 67797ef46f Add more class modifiers to dart:collection.
Pure interfaces made `interface`s
implementation classes which cannot/should not be extended made `final`.

A class like `HasHMap` which provides the `Map` interface,
and no implementation except factory constructors
for internal implementations, is made `final`.

Unified {List,Set,Map}{Base,Mixin} into their `Base` class.
Deprecations are retained in comments for now, to be landed
separately. Search for '// TODO: @Deprecated'.

Tested: No new test, only adding restrictions on use.
CoreLibraryReviewExempt: Everybody's on vacation, everybody everywhere.
Change-Id: Ia83b8a3bb20b5b214546b328d4492de6658253db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288240
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-04-04 10:39:48 +00:00
Lasse R.H. Nielsen f0e099ec5b Add DateTime.timestamp() constructor for "now as UTC".
Change-Id: I497f335b1f1eb0f691c2d44557c50f0f55358426
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292003
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-31 20:52:31 +00:00
Lasse R.H. Nielsen 9e76983782 Reland "Add more interface and final modifiers to dart:core."
This is another reland of 4f8333e80e.
Third time is the charm.

CoreLibraryReviewExempt: Reland of accepted CL.
Change-Id: I4ea8326af91c168b044d252162571d3fe697e4b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289826
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
2023-03-30 20:34:09 +00:00
Lasse R.H. Nielsen d274ef0a4a Fix bug in Duration.toString.
On the web, some inputs to `Duration` would make -0.0
occur in positions where the code assumed an integer
with a reasonable `toString`.

Adds `+ 0` and using `0 - x` instead of `-x` to
avoid ever ending up with a `-0.0`.

Fixes #51584

CoreLibraryReviewExempt: Bugfix, no API changes.
Change-Id: Idecfaf049f2ae5677792387ce24e95add99596cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291280
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2023-03-30 14:02:38 +00:00
Devon Carew 9efc02e741 [doc updates] adjust header level for two core libraries
Change-Id: I8f9de631a5fc33a811b1a4355337a0efd6c1ce00
CoreLibraryReviewExempt: dartdoc comment only changes to core libraries, reviewed by Lasse
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288600
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2023-03-15 17:14:43 +00:00
Devon Carew a548eb9bd2 [sdk docs] update sdk libraries to use triple slash docs
Change-Id: I9ee4d630763042031a06d05fb477f79deb32885b
CoreLibraryReviewExempt: dartdoc only changes, mostly to web libraries (web team reviewed)
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288323
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-03-14 19:10:25 +00:00
Ilya Yanok 936cdeeb2f Revert "Reland "Add more interface and final modifiers to dart:core.""
This reverts commit e293eb809d.

Reason for revert: Breaks G3.

Original change's description:
> Reland "Add more `interface` and `final` modifiers to `dart:core`."
>
> This is a reland of commit 4f8333e80e
>
> Blocked on Flutter patch: https://github.com/flutter/engine/pull/40175
>
> Original change's description:
> > Add more `interface` and `final` modifiers to `dart:core`.
> >
> > Make intent explicit for classes which are intended as interfaces,
> > or which are not intended to be subclassed.
> >
> > Mainly classes which are pure interfaces are marked as such,
> > and platform-specific classes not intended for subclassing
> > are made `final`.
> >
> > The `final` classes includes `BigInt`, which is written to assume
> > that arguments inherit its private members
> > (it runs `_ensureSystemBigInt` on arguments).
> >
> > It also includes the `Expando`, `WeakReference` and `Finalizer` classes,
> > which are just intended as stand-alone implementation classes for accessing
> > platform-specific functionality.
> >
> > Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Commit-Queue: Lasse Nielsen <lrn@google.com>
> > Reviewed-by: Aske Simon Christensen <askesc@google.com>
> > Reviewed-by: Nate Bosch <nbosch@google.com>
> > Reviewed-by: Martin Kustermann <kustermann@google.com>
>
> CoreLibraryReviewExempt: Accepted in original CL.
> Change-Id: Id713edede4228801bb097a64734be4f2187f51a9
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288206
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I05ff2fe44e5a13f20725eb122963d20243062c7a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288503
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Ilya Yanok <yanok@google.com>
2023-03-13 16:08:31 +00:00
Lasse R.H. Nielsen e293eb809d Reland "Add more interface and final modifiers to dart:core."
This is a reland of commit 4f8333e80e

Blocked on Flutter patch: https://github.com/flutter/engine/pull/40175

Original change's description:
> Add more `interface` and `final` modifiers to `dart:core`.
>
> Make intent explicit for classes which are intended as interfaces,
> or which are not intended to be subclassed.
>
> Mainly classes which are pure interfaces are marked as such,
> and platform-specific classes not intended for subclassing
> are made `final`.
>
> The `final` classes includes `BigInt`, which is written to assume
> that arguments inherit its private members
> (it runs `_ensureSystemBigInt` on arguments).
>
> It also includes the `Expando`, `WeakReference` and `Finalizer` classes,
> which are just intended as stand-alone implementation classes for accessing
> platform-specific functionality.
>
> Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180
> Reviewed-by: Stephen Adams <sra@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

CoreLibraryReviewExempt: Accepted in original CL.
Change-Id: Id713edede4228801bb097a64734be4f2187f51a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288206
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-13 15:21:30 +00:00
Lasse R.H. Nielsen c974c70f31 Add boolean parse
Closes https://github.com/dart-lang/sdk/pull/51026

Co-authored-by: Renato Burton <renatoburton96@gmail.com>
GitOrigin-RevId: e85a56ce338476b38eac890fac2b8ca193ca42e8
Change-Id: I60f92c594830ef0438ecd92b4c83cec609054326
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279746
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-03-09 15:14:32 +00:00
Oleh Prypin 732d1cc0a4 Revert "Add more interface and final modifiers to dart:core."
This reverts commit 4f8333e80e.

Reason for revert: causes breakages in google3

Original change's description:
> Add more `interface` and `final` modifiers to `dart:core`.
>
> Make intent explicit for classes which are intended as interfaces,
> or which are not intended to be subclassed.
>
> Mainly classes which are pure interfaces are marked as such,
> and platform-specific classes not intended for subclassing
> are made `final`.
>
> The `final` classes includes `BigInt`, which is written to assume
> that arguments inherit its private members
> (it runs `_ensureSystemBigInt` on arguments).
>
> It also includes the `Expando`, `WeakReference` and `Finalizer` classes,
> which are just intended as stand-alone implementation classes for accessing
> platform-specific functionality.
>
> Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180
> Reviewed-by: Stephen Adams <sra@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I94ff95f72410a4e1ae80744971c4c920fecc1493
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287760
Reviewed-by: Martin Kustermann <kustermann@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-03-09 13:09:57 +00:00
Lasse R.H. Nielsen 4f8333e80e Add more interface and final modifiers to dart:core.
Make intent explicit for classes which are intended as interfaces,
or which are not intended to be subclassed.

Mainly classes which are pure interfaces are marked as such,
and platform-specific classes not intended for subclassing
are made `final`.

The `final` classes includes `BigInt`, which is written to assume
that arguments inherit its private members
(it runs `_ensureSystemBigInt` on arguments).

It also includes the `Expando`, `WeakReference` and `Finalizer` classes,
which are just intended as stand-alone implementation classes for accessing
platform-specific functionality.

Change-Id: Ib770c265edff127a289a67fe72d15b9ff0499407
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/287180
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-09 12:31:08 +00:00
Lasse R.H. Nielsen cc736dfb65 [flip-modifiers]: Reapply "Enforce current library restrictions."
This reapplies commit 0c05e33836
and reverts the revert 029e0cec71.

Tested: Added few new tests, updated existing. Mainly regression testing.
CoreLibraryReviewExempt: Reviewed in original CL.
Change-Id: Ifcc79ce2f9375f607722643a04957b0961e6c295
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284304
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-03-03 09:37:38 +00:00
Ilya Yanok 029e0cec71 Revert "Enforce current library restrictions."
This reverts commit 0c05e33836.

Reason for revert: breaks ~10% of G3 smoke suite.

Original change's description:
> Enforce current library restrictions.
>
> Mark all currently unimplementable types as `final`, or `sealed` for `num` and `final` for `Function`.
> Mark all current classes intended as mixins as `mixin class`.
>
> More additions and cleanup will follow,
> but this change should make everything keep working as today
> if we flip the switch.
>
> TEST= No new tests, very little actual change, covered by existing tests with few changes. Will add more tests when adding more modifiers.
>
> Change-Id: I40e724f823e7f88cdef186d2f73874df256e2f43
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281683
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Aske Simon Christensen <askesc@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Kallen Tu <kallentu@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: Ib0cb5b7ec1a8c392bbf9bf4af8dc3efc0b27991d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/284187
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Ilya Yanok <yanok@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-02-20 15:29:41 +00:00
Lasse R.H. Nielsen 0c05e33836 Enforce current library restrictions.
Mark all currently unimplementable types as `final`, or `sealed` for `num` and `final` for `Function`.
Mark all current classes intended as mixins as `mixin class`.

More additions and cleanup will follow,
but this change should make everything keep working as today
if we flip the switch.

TEST= No new tests, very little actual change, covered by existing tests with few changes. Will add more tests when adding more modifiers.

Change-Id: I40e724f823e7f88cdef186d2f73874df256e2f43
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281683
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2023-02-18 12:37:40 +00:00
Michael Thomsen 6194adf8ea Cross-link from Exception to Error
Change-Id: I6179032ac6cfd1057911e7421843475504974850
CoreLibraryReviewExempt: Documentation only.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282024
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Michael Thomsen <mit@google.com>
2023-02-09 14:15:09 +00:00
Josh Soref 77978889eb Spelling
Closes https://github.com/dart-lang/sdk/pull/51143

GitOrigin-RevId: 9e21c99a222d588e4fc95980725a2f8c9784965c
Change-Id: If0870e8936c7649935dce7e23cd783d62aa5610c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279916
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2023-01-30 18:29:59 +00:00