Commit graph

22422 commits

Author SHA1 Message Date
Paul Berry bf4a94c625 Fix tearoff of methods from promotable variables.
Fixes #51853.

Bug: https://github.com/dart-lang/sdk/issues/51853
Change-Id: I407a1d5fb8b00f983cfcf106d1f569d0642058c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292764
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-04-03 19:39:59 +00:00
Srujan Gaddam e95b84ed41 [dart2js] Fix native null assertions for Dart 3
Allows the following semantics:
- If the disable flag is passed, never check
- If we're in non-sound mode, never check to avoid a breaking
change (this was the behavior before)
- If the enable flag was passed and we're in sound mode,
always check
- If we're in sound mode and with >= -03, don't check

Discussion in https://github.com/dart-lang/sdk/issues/50710

Change-Id: If83aaebb2745e4c8bcaa3f5a38ff41d79a869b8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289451
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-04-03 18:05:28 +00:00
Konstantin Shcheglov e2520f88ef Fixes for a couple pattern tests.
Change-Id: I117890c1117dacac9be11bd1775e8bc42a935c52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292500
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-04-03 17:35:10 +00:00
Daco Harkes 7cfab4e12c [infra/ffi] Skip FFI tests on simulator
Some recent infra shuffling [0] caused FFI tests not to be ingored on
some simulator architectures.

FFI is not supported on simulators, so ignore tests.

[0] https://dart-review.googlesource.com/c/sdk/+/286360

Bug: https://github.com/dart-lang/sdk/issues/48365
Change-Id: Id623733e89f4269feabbe1f1212bdb64a43d7540
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292821
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-04-03 16:14:02 +00:00
Lasse R.H. Nielsen 51cbaed621 Reland "Fix bug in Completer.complete."
This is a reland of commit 3688a4723c

Original change's description:
> Fix bug in Completer.complete.
>
> When given a completed `_Future`, it would complete its own future synchronously.
>
> Fixes #48493.
>
> Bug: https://github.com/dart-lang/sdk/issues/48493
> Change-Id: Ic4a68389b5a009ef52b3875bf03a3bafb493f79a
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234981
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

CoreLibraryReviewExempt: Bugfix.
Bug: https://github.com/dart-lang/sdk/issues/48493
Change-Id: If3a240b5b6eb016e8abe9a2c7551bfcaeea0da4b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278920
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-04-03 14:22:26 +00:00
Paul Berry 406bdf33e8 Fix precedence of expression inside relational patterns.
According to the spec, the expression inside a relational pattern is
`bitwiseOrExpression`.  We were only allowing `shiftExpression`.

Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Ie1a5746f1060b84e6e1b856a622e89db698b4684
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292285
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2023-04-01 16:30:49 +00:00
Robert Nystrom cd519446b6 Fix the exhaustiveness language tests.
The implementations are doing the right thing, but the tests are
slightly off:

- The CFE doesn't report unreachable case warnings because they are
  non-fatal warnings, so remove those expectations. (But analyzer does,
  so continue to check that analyzer reports them.)

- The CFE reports shared case variable errors at a different location.

Change-Id: I7143a7705d3c8879fb91e5fdb8df8599bfb96165
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292520
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-04-01 01:32:56 +00:00
Robert Nystrom 39e128529c Add a couple of exhaustiveness tests.
Just corner cases that occurred to me while specifying the
implementation. There's probably already front end tests for it too, but
I like the idea of having some language coverage as well.

Change-Id: I158f274483799c3ccb29c32f0e7c5c42d31f327f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291962
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-01 01:24:36 +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
Robert Nystrom 0196a5b296 Allow static error tests to detect unreachable case hints from analyzer.
Eventually, these hints should probably be moved over to warnings. But
for now, this makes it possible to write static error language tests
that validate that analyzer produces unreachable case warnings/hints
where expected.

Also updated the patterns/ and switch/ tests now that those errors must
be expected by the test.

Change-Id: If1fb92602c4bde2819b9eec73598033009054947
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291967
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-03-31 20:50:52 +00:00
Paul Berry d2184a9d03 Patterns parsing: disallow unaryPattern or relationalPattern in unaryPattern.
The precedence-based pattern parser can understand a unary pattern
inside another unary pattern (e.g. `_ as int as num`) or a relational
pattern inside a unary pattern (e.g. `> 1?`), but the specification
prohibits these constructions because they're difficult to read and
not very useful.

This change updates the implementation to match the spec, by producing
the appropriate error.  The offset and length of the error cover the
inner pattern, so it should be easy to construct an analysis server
quick fix that inserts the necessary parentheses.

Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I33e74d6d1f863e7162851d26fefbacd4fd17277c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292120
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-03-31 16:43:01 +00:00
Daco Harkes 3de5d25429 [vm] Class modifiers for NativeFieldWrapper subtypes
Split off https://dart-review.googlesource.com/c/sdk/+/291761.
Landing separately, so that the breaking change itself is a smaller
CL.

TEST=ci build (see touched _test files)

bug: https://github.com/dart-lang/sdk/issues/51896
Change-Id: Ic8d218845ccb6a277689e911b2c34c44639e13cf
Cq-Include-Trybots: luci.dart.try:flutter-linux-try,vm-aot-linux-debug-x64c-try,vm-ffi-android-debug-arm-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292000
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2023-03-31 13:20:19 +00:00
Paul Berry 452dcdf517 Fix parsing of PATTERN as T? when
The logic for parsing types has special disambiguation rules for
deciding whether a trailing `?` should be included in the type, based
on what token(s) follow the `?`.  In the case where the token that
follows the `?` is `when`, we need to look further ahead to
disambiguate, to distinguish `PATTERN as T? when guard` from something
like `EXPRESSION is T ? when : otherwise`.

(Note: an alternative implementation would be to disambiguate based on
whether we're parsing a pattern or an expression.  But in the future I
want to move toward an architecture where expression parsing and
pattern parsing are combined, so that if the parser makes the wrong
decision about whether it's looking at a pattern or an expression,
error recovery will do a better job.  So I'm disambiguating based
solely on what follows the `?`.)

Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Idbc780b7b54fecc7fd01cae868c34771564dd804
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292282
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-03-31 13:12:48 +00:00
Chloe Stefantsova 9598da006c Remove duplicated keys from a language test
Change-Id: Ic88e9ee5204167184bb69a605c3b38d951867629
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292321
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-03-31 12:24:13 +00:00
Mayank Patke 5d859bb463 [dart2js] Add test for issue #51910.
Bug: #51910
Change-Id: I0ee968a88e67279d1ced7e1f1126357b0e1bc6b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292260
Reviewed-by: Stephen Adams <sra@google.com>
2023-03-31 02:14:46 +00:00
Robert Nystrom 15e5ec93f3 Update test for 2.29/2.30 changes to map patterns.
It is still an error to have duplicate keys.

Change-Id: Id86fa7b50c3620540f4bef0399f5f70316848662
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292125
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-03-31 01:30:54 +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
Paul Berry 134007af32 Patterns parsing: make it an error to use var before a type in a variable pattern.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I46b23ef0d1856401eac4b0a05c6bc6008711d35a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291780
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-03-30 18:25:03 +00:00
Konstantin Shcheglov 1ec1e7358a Changes for map pattern: report an error for rest elements, empty map pattern.
Bug: https://github.com/dart-lang/language/issues/2861
Change-Id: I00ccb3ea03aa476f96c2ecf3e3a9e13bd4926193
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Marya Belanger <mbelanger@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2023-03-30 17:54:06 +00:00
Paul Berry 104ac30cf4 Parser: clean up handling of variable patterns.
The listener API for variable patterns is split into three separate
functions, to handle the three separate behaviors:

- `handleAssignedVariablePattern` for variable names appearing in an
  assignment context (these assign to an existing variable upon a
  successful match).

- `handleDeclaredVariablePattern` for variable declarations appearing
  in a declaration or matching context (these cause a new variable
  name to come into scope).

- `handleWildcardPattern` for wildcards in any context (these don't
  capture the matched value).

Also, responsibility is shifted to the parser for reporting the
following error conditions:

- VariablePatternKeywordInDeclarationContext (e.g.
  `var (var x) = ...;`)

- PatternAssignmentDeclaresVariable (e.g. `[x, var y] = ...;`)

Previously these errors were detected by the implementations, and
weren't fully covering all possible error scenarios.

In the case of VariablePatternKeywordInDeclarationContext, the
listener method `handleDeclaredVariablePattern` is called instead of
`handleAssignedVariablePattern`.  This ensures that no tokens are
dropped from the analyzer AST.  The CFE uses the `inAssignmentPattern`
argument of `handleDeclaredVariablePattern` to distinguish this error
recovery case from a legitimate declared variable pattern.

Fixes #51868.

Bug: https://github.com/dart-lang/sdk/issues/51868
Change-Id: I28ec679b73d64033166721c6460be35f15e23171
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291583
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-03-30 14:12:03 +00:00
Chloe Stefantsova 81df57636f [cfe] Coerce operands of relational patterns
Closes https://github.com/dart-lang/sdk/issues/51871

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

Change-Id: I13a28c4849002f189ce6c14df2efaacac2ea4bf8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292001
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-30 14:11: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
Kallen Tu f7bc72fce6 [analyzer/cfe] Remove interface mixin, final mixin and sealed mixin.
Added error messages for when users try to use invalid mixins + a language test that tests that (and tests in each of the front ends).

Removed the tokens from the parser listeners.

Removed all behaviours and error reporting related to these invalid mixins.

Change-Id: I558595826dae7e2c176bd1929e97caa2335c167c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290614
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-30 11:56:08 +00:00
Leaf Petersen a7f2562b38 Fix syntax errors and add missing cases in guard_error_test.
Change-Id: I2cc53a7f41721fd146051502ee2f9e102656ed61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291968
Auto-Submit: Leaf Petersen <leafp@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2023-03-30 10:29:22 +00:00
Robert Nystrom 5138b803c9 Add tests for the proposal version 2.29 changes to patterns.
Change-Id: I4b3325213905bc8a80b6fbacbfcf97694e98a60c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291960
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
2023-03-29 23:17:20 +00:00
Lasse R.H. Nielsen f6ac970290 Reland "Add class modifiers to dart:convert." again.
This is a reland of commit 608934e330

Can be landed when Flutter with https://github.com/flutter/flutter/pull/123211
has been rolled into internal repository.



Original change's description:
> Reland "Add class modifiers to `dart:convert`."
>
> This is a reland of commit b2f4cf3e01
>
> Commented out deprecation for now.
>
> Original change's description:
> > Add class modifiers to `dart:convert`.
> >
> > The usual approach:
> > Pure interfaces marked `interface`.
> > Pure implementation classes marked `final`.
> > Base classes marked `base` or nothing, and `mixin class` if reasonable.
> > Combined X/XBase/XMixin where possible.
> >
> > CoreLibraryReviewExempt: Aske is away
> > Change-Id: I927f9bd488fb385ff9c17c8fc94920a1f5076347
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289200
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Reviewed-by: Nate Bosch <nbosch@google.com>
> > Commit-Queue: Lasse Nielsen <lrn@google.com>
>
> CoreLibraryReviewExempt: Approved in original.
> Change-Id: I1bc14f99b742567e2634dcfcbc52f332dbcc5364
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290521
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

CoreLibraryReviewExempt: Approved in original.
Change-Id: If157e1ef2339d7a06e99a1e402f2f8ac93550b83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290960
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-03-29 16:54:23 +00:00
Kallen Tu f76f84c850 [cfe] Report error when sealed or final used in on type outside of library.
Then when using a final class in an on clause outside of its library, we don't produce a base/final subtype error.

Change-Id: Ib96efefb04639496daeee0de98c5711e73709ac5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291591
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-03-29 12:09:23 +00:00
Nate Biggs f9fba691ea [tests] Add language test for field accesses on constant-like record.
Change-Id: I4748f14fd77e4422823af2b7e60d61a57339e19c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291641
Commit-Queue: Nate Biggs <natebiggs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-03-28 22:02:52 +00:00
Kallen Tu 6779635eb0 [cfe] Only report base/final subtype errors on the nearest problematic subtype.
To match up with analyzer behaviour, we want to only report subtype errors
on the first erroneous subtype instead of every subtype down the tree.

Change-Id: Ifb93ef39498e93d075a475fff8939017b563414e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291344
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-03-28 19:07:57 +00:00
Brian Quinlan d884d1a76e [io] Do delayed IPv6 lookups on all platforms.
Bug: https://github.com/dart-lang/sdk/issues/50868
Change-Id: I5ad57f4634287b4299fbf74fde075d518154bf08
Tested: unit
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288621
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2023-03-28 18:17:54 +00:00
Martin Kustermann 0012890cc8 [vm] Add class modifiers to dart:isolate
SendPort/ReceivePort/RawReceivePort become interface classes as there
are existing implementations of those classes (e.g. `package:isolate`
has `Multiplex*Port` classes those).

Since Capability is implemented by SendPort it also becomes an interface
class.

All remaining classes become final - we can always be less restrictive
in the future if needed.

It seems good practice to also add modifiers to private classes (one
reason is that private classes can be exported via e.g. typdef).

TEST=ci

CoreLibraryReviewExempt: No API changes except for modifiers, vm-only library.
Change-Id: I5edf04624a5dc588ac5f49bb898f29b5bc121d5f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288201
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2023-03-28 12:36:45 +00:00
Kallen Tu e0ab0d1be5 [analyzer] Report error when sealed or final used in on type outside of library.
Also, when using a final class in an on clause outside of its library, we don't produce a base/final subtype error.

Change-Id: I6600bc136ca37e98f9698c604214a6c565d6a9af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290263
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-03-27 22:33:29 +00:00
Ryan Macnak bc23aa8078 [test] Remove unnecessary use of exit.
Exit has global destructor races that are flakily flagged by MSAN.

Bug: https://github.com/dart-lang/sdk/issues/51862
Bug: https://github.com/dart-lang/sdk/issues/51560
Change-Id: I50a58c6107776a78d09f4d658f6daba249026ac1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291305
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-27 22:17:52 +00:00
Alexander Aprelev 67683c3973 [vm/isolates] Introduce 'vm:isolate-unsendable' pragma.
Decorate Zone, Future, Completer, Timer and Stream with newly-introduced pragma to make sure that message verification stops earlier, produces shorter retaining path for the user.

BUG=https://github.com/dart-lang/sdk/issues/51722
TEST=send_unsupported_objects_test,isolate_exit_unsendable_test.dart
CoreLibraryReviewExempt: vm-specific pragmas
Change-Id: I499eea542d228ac9cf0797a682664f93f360dc80
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289027
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2023-03-27 20:54:11 +00:00
Kallen Tu fd1b48d82e [tests] Remove interface mixin, final mixin, and sealed mixin from language tests.
Change-Id: I8d92758c3a43ed0eff2e0c953ae8a87e65a3a920
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291047
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-03-24 23:04:47 +00:00
Leaf Petersen 386825ee8c Add tests for the transitivity of the base modifier when applied to
base mixins and base mixin classes.

Change-Id: Idfe7576f38382c5e9a0ff968aae00f48990e1d38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290351
Commit-Queue: Leaf Petersen <leafp@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2023-03-24 21:59:23 +00:00
Paul Berry df7c4bb439 Allow empty switch expressions.
This an experimental change; we haven't yet decided whether we want to
allow this.  See https://github.com/dart-lang/language/issues/2939 for
discussion.

Bug: https://github.com/dart-lang/language/issues/2939
Change-Id: If69ab66d18ae7ec3dfc79496ce13517ef1c15227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290907
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-03-24 20:22:52 +00:00
Kallen Tu 24d210a18c [tests] Fix existing on clause tests for final classes.
Disallow using final classes on on-clauses outside of its library.
Update tests to show this behaviour. (Or at least in a state where I can test out the implementation)

Change-Id: I74306c873dbd047c6b94d8e8e75c215562dd9483
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290915
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-03-24 18:07:52 +00:00
Kallen Tu 2e19faaec9 [cfe] Report an error when implementing a base class through a sealed class.
Bug: https://github.com/dart-lang/sdk/issues/51811
Change-Id: Ifad0519332965d79719173702293b48e94231024
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291040
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-03-24 17:09:09 +00:00
Paul Berry c175d48343 Front end: fix type inference for object patterns that refer to typedefs.
I've also added some runtime checks to
`tests/language/patterns/object_pattern_inference_test.dart` to verify
that the object patterns match when they should match and don't match
when they shouldn't; this helps verify that not only has the front end
inferred the correct type for the object patterns, but it has also
stored the correct type in the kernel representation.

Fixes #51795.

Bug: https://github.com/dart-lang/sdk/issues/51795
Change-Id: I73ce43e440db50d9942deb4a1eb4ee68a5c23142
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290900
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-03-24 12:20:08 +00:00
Robert Nystrom c89ec96b96 Fix int-to-double test to work on the web.
Change-Id: I5e208edc53543de8d11aa6e81072ad7f61a23d52
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290913
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-03-23 22:47:49 +00:00
Kallen Tu 66c1b0db50 [analyzer] Report an error when implementing a base class through a sealed class.
Bug: https://github.com/dart-lang/sdk/issues/51810
Change-Id: I478eff8484fa5d3bddfb9cf1c744e6d65a72f6c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290400
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2023-03-23 22:06:01 +00:00
Paul Berry c358118e9f When type inference fails for object patterns, fall back on instantiate-to-bounds
(As discussed in https://github.com/dart-lang/language/issues/2770#issuecomment-1479624850)

Fortunately this was easy to do because we already have the necessary
logic to fall back on instantiate-to-bounds when type inference fails;
it's a standard part of the "upwards inference" algorithm.

Bug: https://github.com/dart-lang/language/issues/2770, https://github.com/dart-lang/sdk/issues/51795
Change-Id: I91847fc01d1420e6bfb584e8536ebca803133bd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290613
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-03-23 13:13:20 +00:00
Emmanuel Pellereau d0556f9c27 Revert "Reland "Add class modifiers to dart:convert.""
This reverts commit 608934e330.

Reason for revert: breaks google3. See b/274843808.

Original change's description:
> Reland "Add class modifiers to `dart:convert`."
>
> This is a reland of commit b2f4cf3e01
>
> Commented out deprecation for now.
>
> Original change's description:
> > Add class modifiers to `dart:convert`.
> >
> > The usual approach:
> > Pure interfaces marked `interface`.
> > Pure implementation classes marked `final`.
> > Base classes marked `base` or nothing, and `mixin class` if reasonable.
> > Combined X/XBase/XMixin where possible.
> >
> > CoreLibraryReviewExempt: Aske is away
> > Change-Id: I927f9bd488fb385ff9c17c8fc94920a1f5076347
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289200
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Reviewed-by: Slava Egorov <vegorov@google.com>
> > Reviewed-by: Nate Bosch <nbosch@google.com>
> > Commit-Queue: Lasse Nielsen <lrn@google.com>
>
> CoreLibraryReviewExempt: Approved in original.
> Change-Id: I1bc14f99b742567e2634dcfcbc52f332dbcc5364
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290521
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

Change-Id: Ie438531e9b97658c86e242fabddbb8a2919f634b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290763
Reviewed-by: Alexander Thomas <athom@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Oleh Prypin <oprypin@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
2023-03-23 12:19:33 +00:00
Joshua Litt 884f42a4f4 [js_util] Make callMethod take an Object method.
CoreLibraryReviewExempt: Minor refactor of web only library.
Change-Id: I7afc4a00501ac12c1aa0248305001a978f2e9f8f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288641
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2023-03-23 00:23:00 +00:00
Kallen Tu c7cee7fd46 [tests] Update tests where analyzer mixin applications were failing.
Bug: https://github.com/dart-lang/sdk/issues/51808
Change-Id: I0c3951ab28f96cf1794e0ac1088c975c11935bf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290660
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2023-03-22 22:51:34 +00:00
Stephen Adams 7675d887b3 Add test for http://dartbug.com/51527
Test currently fails on both DDC and dart2js

Bug: 51527
Change-Id: I229d5c9ba518d3323f98312f13740711523439e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290350
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
2023-03-22 20:09:03 +00:00
Paul Berry 6b4878b55f Front end: initial implementation of type inference for object patterns.
This code handles simple cases.  Still TBD:
- Object patterns that refer to typedefs
- Object patterns that refer to classes with f-bounded polymorphism
- Inference of `dynamic` when there is no bound

Bug: https://github.com/dart-lang/sdk/issues/51795
Change-Id: I00acae6ba111f7b170650cfeffbfd2aaf7f71e42
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290347
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2023-03-22 17:19:23 +00:00
Mark Zhou 6872707aa6 [ddc] Fixing switch label finder.
Our previous visitor was manually implemented. Extending the recursive visitor instead helps us be more robust to future CFE updates.

Fixes #51802

Change-Id: I9efebdf28fdf9146c2d1f948e01363a77807aa16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290280
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2023-03-22 16:35:18 +00:00
Lasse R.H. Nielsen 608934e330 Reland "Add class modifiers to dart:convert."
This is a reland of commit b2f4cf3e01

Commented out deprecation for now.

Original change's description:
> Add class modifiers to `dart:convert`.
>
> The usual approach:
> Pure interfaces marked `interface`.
> Pure implementation classes marked `final`.
> Base classes marked `base` or nothing, and `mixin class` if reasonable.
> Combined X/XBase/XMixin where possible.
>
> CoreLibraryReviewExempt: Aske is away
> Change-Id: I927f9bd488fb385ff9c17c8fc94920a1f5076347
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289200
> Reviewed-by: Stephen Adams <sra@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Reviewed-by: Nate Bosch <nbosch@google.com>
> Commit-Queue: Lasse Nielsen <lrn@google.com>

CoreLibraryReviewExempt: Approved in original.
Change-Id: I1bc14f99b742567e2634dcfcbc52f332dbcc5364
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290521
Reviewed-by: Nate Bosch <nbosch@google.com>
Commit-Queue: Lasse Nielsen <lrn@google.com>
2023-03-22 15:34:38 +00:00