Commit graph

22531 commits

Author SHA1 Message Date
Konstantin Shcheglov c0d33e45d1 Issue 52151. Fixes for reachability in switch patterns when unresolved / error type.
Bug: https://github.com/dart-lang/sdk/issues/52151
Change-Id: Ib56df1711cbfb7a593c7b16fd6a67e45baeabc3c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302455
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-12 19:16:42 +00:00
Nicholas Shahan f2aa312e17 [ddc] Implement new record types
Update the format of the shape keys to better match the format used in
the dart:_rti library. This change applies to the current runtime type 
system as well.

Change-Id: I87d2af2aaf2b9dbe012fae60a64718d264a3a18c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295721
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-05-12 17:23:07 +00:00
Konstantin Shcheglov 42c79709a4 Separate isDynamicBounded() and isInvalidBounded().
Also includes https://dart-review.googlesource.com/c/sdk/+/302680
that was reverted because of adding extre diagnostics for Flutter.

Change-Id: I4cf7cedfcb67a5af226e609d279551fea0b0dee1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302844
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-12 15:12:38 +00:00
Nicholas Shahan f469856233 [ddc] Temporarily skip tests that timeout
These tests are flaky or timing out on the stable DDC configurations.
This change adds skips for the canary configurations to avoid crashing
the infra when too many tests that timeout are attempted to be
deflaked.

When the canary mode stabilizes we should manually mark all these
tests as flaky if they are still not passing on the stable DDC
configurations.

Issue: https://github.com/dart-lang/sdk/issues/50666
Change-Id: I9b1cb8fe466624480767fea05610331bf0f4ed87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302843
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-05-11 23:03:38 +00:00
Emmanuel Pellereau d3c7e183e9 Revert "Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything."
This reverts commit 838c926f64.

Reason for revert: breaks google3. See b/281948666

Original change's description:
> Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything.
>
> Bug: https://github.com/dart-lang/sdk/issues/35828
> Change-Id: Ie7757cb2e0cbc0cfdd1530b75f34ffb3dd3156dd
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302680
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
> Reviewed-by: Samuel Rawlins <srawlins@google.com>

Bug: https://github.com/dart-lang/sdk/issues/35828
Change-Id: I05ddcf7657069b1e889b5b0019faaf7301f6643b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302781
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2023-05-11 14:00:06 +00:00
Alexander Aprelev 3a668dcf03 [vm/win/aot] Provide unwinding information for Windows AOT snapshots.
Fixes https://github.com/dart-lang/sdk/issues/52045
TEST=ffi_induce_a_crash_test

Change-Id: Ic047df10732d6ff8cf695ce098d80ec3a098dbf9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302380
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2023-05-11 03:14:27 +00:00
Konstantin Shcheglov 838c926f64 Issue 35828. Don't report COULD_NOT_INFER when InvalidType, make it a subtype of everything.
Bug: https://github.com/dart-lang/sdk/issues/35828
Change-Id: Ie7757cb2e0cbc0cfdd1530b75f34ffb3dd3156dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302680
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-11 01:05:51 +00:00
Kallen Tu 9c34ff75db [analyzer] Produce error when omitting base/final/sealed on base/final superclasses through legacy libraries.
When a post-feature library implements a pre-feature library declaration that has a final core library class as a super declaration, it should not produce a base/final/sealed transitivity error. Subclasses of a base core library class will still emit this error.

Otherwise, if base/sealed/final is omitted in a non-implement case, we want to report these errors.

Bug: https://github.com/dart-lang/sdk/issues/52315
Change-Id: Icdd4f63f69b061be5eabc7fd30b703d0358018a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302365
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-10 22:05:59 +00:00
Paul Berry cb0eb28cba Account for differing flow analysis conventions between CFE and shared code.
With one exception (noted below), the shared analysis logic uses the
convention that the expressions passed to flow analysis are the
original (pre-lowered) expressions, whereas the expressions passed to
flow analysis by the CFE are the lowered expressions. This difference
caused two problems:

- If a boolean expression appeared on the right hand side of a pattern
  assignment or pattern variable declaration, and it was lowered, the
  flow analysis implications of that boolean expression would be lost.

- If a boolean expression appeared in a `when` clause, and it was
  lowered, the flow analysis implications of that boolean expression
  would be lost. Exception: for switch statements, the shared analysis
  logic has been passing lowered expressions to flow analysis, so this
  problem didn't occur for `when` clauses in switch statements.

Notably, when compiling for the VM, the CFE lowers expressions like
`x != null` to something more like `!(x == null)`.

Fortunately, the first of these two situations shouldn't cause
problems very often, since typically if the right hand side of an
assignment or variable declaration is a boolean expression, there is
no need for the left hand side to involve patterns.

As for the second of these two situations, it's also not too likely to
cause problems, since typically null checks occur inside patterns
rather than in `when` clauses.

As a short term fix, we remove the exception noted above, and we
account for the difference in conventions by adding a call to
`FlowAnalysis.forwardExpression` to the CFE's implementation of
`dispatchExpression`, so that when transitioning between CFE logic and
shared logic, flow analysis will be informed how to match up the
lowered expressions to their pre-lowered counterparts.

Longer term, I would like to switch everything to the convention of
using the original (pre-lowered) expressions; this will bring the
analyzer and CFE into better alignment with each other and should
eliminate a class of subtle bugs. This long term goal is tracked in
https://github.com/dart-lang/sdk/issues/52189.

Fixes #52183.
Fixes #52241.

Bug: https://github.com/dart-lang/sdk/issues/52183, https://github.com/dart-lang/sdk/issues/52241.
Change-Id: I2449ce34c54325603bc2730d1660a7cfc7d79aec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298840
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-10 19:31:19 +00:00
Kallen Tu ea21df9dbe [cfe] Disallow implementing a legacy library subclass of a final/base class in the core libraries.
This behaviour should only happen when a post-feature library implements
a pre-feature library declaration that has a final/base core library class as a super declaration.

Bug: https://github.com/dart-lang/sdk/issues/52115
Change-Id: If42129ba3ba7e337cc6ffc21604c6d0f2976344c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301503
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-10 14:31:50 +00:00
Daco Harkes e5bb28bc4d [vm/ffi] Pointer.asTypedList finalizer
TEST=tests/ffi/external_typed_data_finalizer_test.dart

Closes: https://github.com/dart-lang/sdk/issues/50507
CoreLibraryReviewExempt: https://github.com/dart-lang/sdk/issues/52261
Change-Id: I1a82dcca15961b28c0de64637970fe38a39286e5
Cq-Include-Trybots: luci.dart.try:vm-asan-linux-release-x64-try,vm-aot-asan-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-qemu-linux-release-arm-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-aot-win-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-aot-mac-release-x64-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301001
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2023-05-10 11:38:57 +00:00
Srujan Gaddam 29e814357c [pkg:js] Lower external @staticInterop and extension members using invocation-level semantics
We've changed the semantics for these members using dart:js_interop
so that not passing in optionals on the Dart side is equivalent to
not passing in optionals on the JS side. This CL makes that consistent
with package:js as well.

Modifies CHANGELOG to announce breaking change.

Change-Id: Ic5c33c9c797983a72edec9bc59f60fc1f29240b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300400
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-05-09 23:12:58 +00:00
Srujan Gaddam 8cbd946338 [dart:js_interop] Disallow tear-offs of external members
Disallows tear-offs for all interop members when using
dart:js_interop, and disallow tear-offs of @staticInterop and
extension external members. Creates tear-off indexes in
InlineExtensionIndex to keep track of tear-off methods that
the CFE generates.

Modifies the CHANGELOG to communicate the breaking change.

Change-Id: I900fdfd6ee6b198f2f34e9d9fd5f3d9c964680e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299800
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-05-09 23:12:58 +00:00
Daco Harkes 65630baac9 [gardening] Update status file
Mark in status file instead of with test workflow so that test.py is
fully green and all current triaged failures are marked in status file.

Bug: https://github.com/dart-lang/sdk/issues/39487
Change-Id: Ib0729a9ee68d7f0e0f8a9ad30238e537467f8426
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302322
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
2023-05-09 18:22:56 +00:00
Chloe Stefantsova 40d99bc981 [cfe] Remove extra conditions on await-for in non-async body check
Additionally, report the error on the 'await' keyword instead of 'in'

Change-Id: I0ccd156f19997eb18b5df004a75f86e616b23864
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301021
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-09 06:56:44 +00:00
Kallen Tu 6de1afdb3a [analyzer] Disallow implementing a legacy library subclass of a final class.
Checks an interface's supertypes for final classes and produces an error if the implementing bypasses a legacy library.

This behaviour should only happen when a post-feature library implements
a pre-feature library declaration that has a final class as a super
declaration.

Similar error to https://dart-review.googlesource.com/c/sdk/+/298320

Bug: https://github.com/dart-lang/sdk/issues/52078
Change-Id: Ie16edb2b231957dad7502fdab3d5faba93bc6773
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300861
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-08 23:16:53 +00:00
Paul Berry 3713c0e264 Patterns parser: prohibit variable/identifier patterns named when/as.
In https://dart-review.googlesource.com/c/sdk/+/299400, the parser was
adjusted so that it no longer accepts `when` and `as` as the names for
variable patterns in cases where there is a possible ambiguity
(e.g. `int when` is not accepted as a pattern because `int` is a
legitimate pattern, therefore `when` could introduce a guard
clause). This change further prohibits `when` and `as` from being the
names of variable patterns or identifier patterns even in the case
where there is no ambiguity. This is in line with the discussion at
https://github.com/dart-lang/sdk/issues/52199#issuecomment-1526297771,
and the spec change at
https://github.com/dart-lang/language/pull/3033.

Three new error codes are introduced, to cover the three circumstances
in which `when` or `as` might be used illegally: in a declared
variable pattern, in an assigned variable pattern, or in an identifier
pattern. I've also added analyzer tests to ensure that the parser
recovers from these errors nicely. Unfortunately, nice error recovery
is only feasible in the non-ambiguous cases.

I've also updated the language test expectations in
`tests/language/patterns/version_2_32_changes_error_test.dart` to
reflect the new error messages, and added a few more examples of uses
of `when` and `as` that are still permitted.

Fixes #52260.

Bug: https://github.com/dart-lang/sdk/issues/52260
Change-Id: I229f627aa639659c30b83c74895759207da279f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301482
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-08 19:06:02 +00:00
Daco Harkes 8beb778e64 [analyzer/ffi] Fix spurious FFI errors
Closes: https://github.com/dart-lang/sdk/issues/52298
Change-Id: Ibfccd34a877d5786f4720790b5ff88dcc643c9d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301980
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-05-08 15:16:05 +00:00
Lasse R.H. Nielsen 7536f86775 Add tests for behavior of class modifiers through legacy libraries.
Change-Id: Iebdedf29cfe90c927c84af1564764ce6477d53af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301442
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-05-08 15:05:11 +00:00
Nicholas Shahan dd2fb672fd [ddc] Add regression test for type test issue
In DDC the types [num], [int], [double], [String], and [bool] used in 
bounds caused an "optimization" in type tests that was incorrect when 
passing a subtype as the type argument.

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

Change-Id: I0ae8d21c907cd923d62dbae257085545840a8cdf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301140
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-05-05 21:13:40 +00:00
Konstantin Shcheglov f90c3d0423 Issue 52272. Report DEPRECATED_MIXIN_FUNCTION in more places.
Bug: https://github.com/dart-lang/sdk/issues/52272
Change-Id: I02133f8685adf6a1e4fa16288948cc31afeb1bd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301560
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-05-05 20:02:28 +00:00
Sigmund Cherem 1c59f30d7b [dart2js] fix crash with records and null-assertions.
Our helper function to detect whether a null-assertion was required
didn't include a case to check for record types.

The null-assertion flag is likely to go away soon, since it's
only valuable for mixed applications.

Fixes #52276

Change-Id: Ief4515b8c3eaae5343012da4220e6051bb5a2f19
Fixed: 52276
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301680
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-05-05 17:20:13 +00:00
Kallen Tu 95565e28e2 [tests] Language tests for errors when implementing a 2.19 class that implements a core library base or final class.
Bug: https://github.com/dart-lang/sdk/issues/52078
Change-Id: If97895b9560475f11e8236de87ad5880bdee97c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300880
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-05-04 20:53:42 +00:00
Paul Berry a29487d803 Add tests for proposed version 2.32 changes to patterns.
Bug: https://github.com/dart-lang/sdk/issues/52199
Change-Id: I04fcac4a2b9a7e49a0231441feb764a022dd5ab8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300320
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-05-04 17:28:50 +00:00
Robert Nystrom af07557984 Add (passing) test for type parameters in exhaustiveness checking.
Change-Id: I2b2dc6a586d66c93e918b077bd008c3683986d18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301300
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2023-05-04 12:18:49 +00:00
Liam Appelbe 9d78eaf1ad [gardening] Fix dwarf_stack_trace_invisible_functions_test
https://dart-review.googlesource.com/c/sdk/+/300600 migrated some tests
to use a new TEST_COMPILATION_DIR flag, but this test was incorrectly
migrated. The test was failing on the legacy bots.

Change-Id: Iac6fa3e946dc29d840068813123359262fe59474
TEST=Local testing and CI
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301220
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Liam Appelbe <liama@google.com>
2023-05-03 23:01:48 +00:00
Vyacheslav Egorov 19e56613cf [infra] Prevent VM AOT tests from poluting SDK source.
Extend test_runner VMOptions support with an ability to specify
paths relative to temporary compilation directory.

    // VMOptions=--foo=$TEST_COMPILATION_DIR/foo.file

The same directory will also be passed as an environment variable
to execution command.

Migrate most of the tests which used to write stuff into the SDK
root to use this feature. I am leaving vm/dart/causal/* tests
unmigrated because migrating requires time consuming manual
update of expectations (which encode raw line numbers). I have
a follow up CL which changes how these tests are written which
will make migration trivial.

Change-Id: Id53008be66de8ff18623efac27ff15750f407749
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300600
Reviewed-by: William Hesse <whesse@google.com>
Commit-Queue: Slava Egorov <vegorov@google.com>
2023-05-03 13:24:39 +00:00
Sun Jiao f9ccf90c97 [http] support SameSite in Cookies.
Closes https://github.com/dart-lang/sdk/pull/51457

GitOrigin-RevId: 4e0bece11ae2c1b7b7eac5a43293ae43682e22d2
Change-Id: I0fe39aede037b713b5a3fdbf7950a4a44a02ea1d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283984
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-05-02 23:51:22 +00:00
Lasse R.H. Nielsen 6c86fc44a6 Reland "Fix bug in Completer.complete."
This reverts commit 212d5e3a31.
This reapplies commit 3688a4723c.

CoreLibraryReviewExempt: Refactoring and relanding.
Change-Id: I9b52ef4073bfff50699919f8a5b85e5ff66d0c3b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258929
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
Auto-Submit: Lasse Nielsen <lrn@google.com>
2023-05-02 19:33:57 +00:00
Leaf Petersen 806ba0a0ca Update base transitivity error messages for the CFE.
Change-Id: I036d17deb110559b35c043e1cd660dbcafffed1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300324
Auto-Submit: Leaf Petersen <leafp@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Kallen Tu <kallentu@google.com>
2023-05-02 18:23:49 +00:00
Paul Berry 94862482d2 Test object pattern behavior with nullable and potentially nullable types.
Change-Id: Ic9075cdbb0aedd17a00d500c44dc33e1516b940b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300323
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2023-05-02 18:01:53 +00:00
Joshua Litt 85afd7bf30 [js] Add proper error message for incorrect usage of Function.toJS.
Change-Id: Id38166f9e9a2c56a73840de212f2e3f6388ad2ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298240
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-05-02 15:25:38 +00:00
Srujan Gaddam c4d354dc2a Reland "[pkg:js/dart:js_interop] Move annotations to dart:_js_annotations"
This reverts commit 4919729f00.

This CL also adds back in logic to handle older package:js versions to avoid
failures in our static checking. It also supports dart:js_interop's @JS
annotation since it can now be used for @staticInterop classes.

CoreLibraryReviewExempt: Reland of backend-specific library changes.
Change-Id: I104653a9a6b2593f6bab658808287e2074c18550
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294130
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2023-05-02 15:24:18 +00:00
Paul Berry 761b8019ef Update CFE expectation for error test.
Also update the test name to follow test naming conventions (tests
with error expectations are named `*_error_test.dart`), and add a
copyright notice and test description.

Bug: https://github.com/dart-lang/sdk/issues/52202
Change-Id: I762dcbf6ebd02190250ccdd9767e6db29cac1d61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300322
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-05-01 21:27:12 +00:00
Nicholas Shahan f7e8677ff6 [ddc] Add DDC specific NSM error test cases
Ensure there are tests for all the different code paths that
throw `NoSuchMethodError` when making some kind of dynamic invocation.

Add tests to cover the name descriptors that appear as well. Some are
confusing and in need of improvement. 

Null values in particular will cause a crash before correctly throwing
a `NoSuchMethodError`.

Change-Id: I54bbb91214e0d333b1a99abe455c8ff1a4df6cb9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297182
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
2023-05-01 18:39:35 +00:00
Ryan Macnak d2ef2ce26f [ffi] Add failing callback test with an Error that is not an UnhandledException.
Bug: https://github.com/dart-lang/sdk/issues/39487
Change-Id: I54d09341fa4b919e7efe9ea0714c089d2ee91826
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299880
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2023-05-01 16:13:51 +00:00
Daco Harkes 624ce64b01 [gardening] Skip FFI test on Windows AOT
Test in https://dart-review.googlesource.com/c/sdk/+/293541 should be
skipped on Windows AOT.

Bug: https://github.com/dart-lang/sdk/issues/40579
Bug: https://github.com/dart-lang/sdk/issues/51794
Closes: https://github.com/dart-lang/sdk/issues/51966
Change-Id: I06c4f492f97c903cd31f973163b264526a341681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293685
Reviewed-by: Siva Annamalai <asiva@google.com>
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-05-01 08:13:48 +00:00
Paul Berry 637dd76c7f Patterns parsing: fix ambiguity resolution for when and as.
This change fixes parsing of case clauses such as:

    case foo when !flag:

Constructions like this require some lookahead in order to parse
correctly, because the token `when` is valid both as an identifier and
as a part of the grammar for a case clause. Therefore, at the time
`foo` is encountered, the parser must decide whether it is looking at
a variable pattern (`foo when`, where `when` is the name of the
variable) or an identifier pattern (`foo`, where `when` begins the
case's guard clause). Previous to this fix, the algorithm for
disambiguating these two choices was as follows:

- If the token sequence starting at `foo` looked like a type, and the
  token that follows was an identifier, the parser assumed it was
  looking at a variable pattern with a type; otherwise it assumed it
  was looking at an identifier pattern.

- EXCEPT that if the token that followed the supposed type was `when`
  or `as` (both of which are valid identifiers), then it probed
  further:

- If the token that followed `when` or `as` was a token that could
  legitimately follow a pattern, then it assumed that it was looking
  at a variable pattern with a type. (The tokens that could
  legitimately follow a pattern are `,`, `:`, `||`, `&&`, `)`, `}`,
  `]`, `as`, `when`, `?`, `!`).

- Otherwise it assumed that it was looking at an identifier pattern.

This didn't fully disambiguate, because the third bullet didn't
account for the fact that the tokens `as`, `when`, and `!` could
_either_ legitimately follow a pattern _or_ legitimately begin an
expression (or, in the case of `when`, a type), therefore constructs
like the following were incorrectly parsed:

- `case foo when as:` (where `as` is a local boolean variable)
- `case foo when when:` (where `when` is a local boolean variable)
- `case foo when !flag:` (where `flag` is a local boolean variable)
- `case foo as when:` (where `when` is the name of a type)

The solution is to simplify the disambiguation logic so that if if the
token that follows the supposed type is `when` or `as`, then the
parser assumes that it's looking at an identifier pattern, _not_ a
typed variable pattern.

The consequence of this is that the above four constructions are
parsed correctly; however it is no longer possible for a typed
variable pattern to name a variable `when` or `as`.

For consistency we would like to prohibit _any_ variable pattern from
naming a variable `when` or `as`, however to keep this change as small
as possible (and reduce the risk involved in a possible cherry-pick)
that will be postponed until a later CL.

Fixes #52199.

Bug: https://github.com/dart-lang/sdk/issues/52199
Change-Id: Ibab9b92f01e3e4020d7d64f1ff000a9b964a4564
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299400
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-04-28 13:22:28 +00:00
Konstantin Shcheglov 7f503e3688 Issue 52202. Fix crash when object pattern type is potentially nullable.
Bug: https://github.com/dart-lang/sdk/issues/52202
Change-Id: I54068a58f68f46c3d75c1586e6ed575b361a22fc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299380
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-04-28 03:20:39 +00:00
Joshua Litt 47b7c1f31d [js] Add js_interop_unsafe library.
CoreLibraryReviewExempt: Web only library.
Change-Id: I4d6007e0731ecae81fcc614168baee7d5e662fd8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293743
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-04-27 18:51:49 +00:00
Nicholas Shahan 9d0781bd9b [ddc] Refactor NSM error tests
Change-Id: Id88b6809736320b6ae098f40f16ced218649a385
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297181
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-04-27 16:36:58 +00:00
Alexander Aprelev 4b7de54e03 [vm/regex] Pick a fix for unicode negated range RegExp.
Pick up v8 fix https://chromium-review.googlesource.com/c/v8/v8/+/3802690.

Fixes https://github.com/dart-lang/sdk/issues/52182
TEST=corelib/regexp/regexp_test

Change-Id: I01057ec5c8babdafc06ddeea3db48e14ae7c5357
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298700
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-04-26 19:46:06 +00:00
Srujan Gaddam 1d28f8e821 [dart:js_interop/ddc/dart2js] Implement JS types using @staticInterop
Currently, dart:_js_types types are all typedefs in the web backends.
This leads to inconsistent semantics, since you can statically pass
Strings to JSString, for example. You cannot do this in dart2wasm.
In order to ensure consistent semantics, we reify these types using
a custom @staticInterop lowering. They all get erased to their
respective Dart type. When we have inline classes, these types
should be implemented using inline classes.

Note that Interceptor will not work for this use case. The reified
type of JS primitives are Dart types e.g. String, bool, and therefore
can not be casted to Interceptor.

In order to do this, the eraser is refactored and the JS backends use
shared erasure code to either erase/emit types.

Tests are added to make sure you need to go through a conversion or
cast to pass Dart objects to JS types.

CoreLibraryReviewExempt: Backend-specific internal library changes.
Change-Id: I5942be628102919ec167f094cfe10fced606363c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/295105
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-04-26 15:55:54 +00:00
Johnni Winther 2a82ba0f48 [cfe] Report error on indirect implementation of base class
Closes #52161

Change-Id: I9e2f441036cfeeb904a3e3ec5aeff2e5c45cb8a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298160
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2023-04-26 08:16:34 +00:00
Valentin Hăloiu 9a5de8e2ea Fix HTTPS client certificate test
These tests have been broken (and disabled) for a while. This pull-request fixes the tests and re-enables them.

Bug: #47052
Change-Id: Ib8c83959e5f00a2a5dc29959f87adbaa963385fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296863
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2023-04-26 06:45:20 +00:00
Stephen Adams 8ee2b8b36b [dart2js] Convert recordTypes after closureData
Fixed #51899
Change-Id: Id9108e6cf13aee409b127fe6cd007bef8f0fe609
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298460
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-04-26 03:57:07 +00:00
Leaf Petersen 5138a1eb38 Add test cases to cover implementing a base declaration from the
current library which itself extends a base declaration from another
library.

Change-Id: I3caf125de528d5c082c825c02055a114f732f385
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298040
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2023-04-25 21:59:46 +00:00
Robert Nystrom 4bfb196287 Fix web_int_literals_test.dart.
This test was inadvertently broken when automatically migrated from a
multitest to a static error test.

The original intent of the test was to ensure that web compilers
reported compile-time errors on integer literals that couldn't be
represented as JS doubles. The migrated static error test doesn't have
any web expectations and thus doesn't get run on web compilers at all.
Instead, all it does is validate that the one non-web error in there is
reported.

This turns the test into a proper *web* static error test with the
web-specific test expectations in there. That ensures the test is run
on web compilers and validates that the web compilers produce those
expected errors.

Also removed the corresponding runtime test since it doesn't do
anything. There's no runtime behavior to test, and the static error
test also correctly validates that the *valid* integer literals do *not*
produce compile errors.

Removed the status file entries because they're no longer needed. Since
this is a static error test, the runtime platforms already skip it
implicitly.

Change-Id: I2776847e1acb88b1f761efb43e7bb528b27d0eee
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297840
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-04-25 21:28:39 +00:00
Valentin Hăloiu db766b37cb Fix SSL certificate check when hostname is an IP address
Closes https://github.com/dart-lang/sdk/pull/52118

GitOrigin-RevId: 7598354d2ad5baba2ed65177bdff521a637b5b65
Change-Id: I78246e423f6ee090030912576ab8202f0fa60509
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296722
Reviewed-by: Brian Quinlan <bquinlan@google.com>
Commit-Queue: Brian Quinlan <bquinlan@google.com>
2023-04-25 16:06:12 +00:00
Paul Berry 96a346fc5e Front end: move anonymous mixin sealed/final inference to checkSupertypes phase.
Previously this step happened during `buildOutlineNodes`, but since
`buildOutlineNodes` happens in source order, this means that anonymous
mixins would only get their sealed and final attributes properly
inferred if they appeared *after* their immediate supertypes in source
order.  By moving this step to `checkSupertypes`, we ensure that the
computation is correct regardless of source order, because
`checkSupertypes` happens in class hierarchy order.

Fixes #52048.

Bug: https://github.com/dart-lang/sdk/issues/52048
Change-Id: Ib9f1f3dafded88681a26f09e4d21dfd44e70dfd3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297901
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-25 12:26:38 +00:00