Commit graph

88619 commits

Author SHA1 Message Date
Ben Konyi 3850a595b9 [ VM ] Ensure heap sampling profiler is initialized on newly spawned threads
Also fixes some incorrect TLAB boundary calculations

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

TEST=DartAPI_HeapSampling looped under full system load for 30 minutes

Change-Id: I6e56cc659b58f9b246d20dc5b649fc367af9c672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273500
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2022-12-05 17:41:08 +00:00
Ahmed Ashour bea7045517 [analyzer] add failing test case
Bug #50496

Change-Id: Iaa6007af1b9dbbf7bac3f2ad835dece3eb64b189
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271520
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 17:37:43 +00:00
Devon Carew 4b4b3645b8 [dartdev] uncomment the dependencies: section in the create templates
Change-Id: I7ad57d3a2fd357b368e8d2210a6dfef0fe2ed4a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273543
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-12-05 17:34:03 +00:00
Paul Berry c02a050721 Add handleMergedStatementCase.isTerminating boolean.
This can be used by the front end to detect when to add synthetic
break statements to switches involving patterns.

Bug: https://github.com/dart-lang/sdk/issues/50624
Change-Id: I783b0920b8dc6ccbc7af8062fba7bfdeaa9dd9cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273800
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-05 17:10:50 +00:00
Paul Berry 55902d3702 Fix ToSourceVisitor.visitSwitchExpressionCase.
In
b2889872c3,
the switch expression syntax was changed so that it no longer uses the
`case` keyword.

Change-Id: I97c10b3462b5849e1baf386df81a656d5ac25c09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273623
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 16:53:35 +00:00
Paul Berry e7832eba4c Update AstComparator.visitPatternVariableDeclaration to account for metadata.
Change-Id: Icd875b10088cef17b4a3351591e29b1275900a50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273622
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 16:52:26 +00:00
Paul Berry 05ee431fb4 Capture metadata in for-in loops with patterns.
Change-Id: I90607774cfd5ae34b91af36538eb77b7ce0b6a0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273620
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-05 15:44:18 +00:00
Sigurd Meldgaard a890972aee Filter '#' characters from log in tool/manage_deps.dart
Change-Id: Icac7b594a942787477beda2979eb0e427d8dcece
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273780
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
2022-12-05 15:10:30 +00:00
Jens Johansen 93ef21b00b [vm] Add examples to heapsnapshot tool
Change-Id: I2b3735341146e532a747e302050e3983ee8f7e1c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273240
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-05 15:02:27 +00:00
Paul Berry 7a3aa5c7f5 CFE parser test cases for metadata in for-in loops with patterns.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I336b391c9102e4e6dd3eabce1051763e3bc797d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273621
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-05 14:56:41 +00:00
Jens Johansen b0ca324b08 [VM] Fix crash on >num filter in heapsnapshot tool
Change-Id: I873d98452e88d2b55b485cc14daa1823af2ba0f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273741
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2022-12-05 14:49:50 +00:00
Johnni Winther a392d30e1d [cfe] Handle direct access to instance methods and getters in views
Change-Id: I63fbdf31b225ea503f35b85601b8f9718431d6cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273380
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-12-05 10:13:22 +00:00
Erik Ernst ac68a593d4 New test, testing the behavior under scrutiny in SDK issue 49396
Change-Id: I1ebb2ea12f4d01c4077fca6fc380353f821bc68a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267422
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-12-05 09:40:08 +00:00
Sergey G. Grekhov c0330b6444 [co19] Roll co19 to 9cfd817af42a5b3f934829aa1a82b5f27463130f
2022-12-01 sgrekhov22@gmail.com dart-lang/co19#1401. [Patterns] More test cases added to variable and wildcards tests (dart-lang/co19#1551)
2022-12-01 sgrekhov22@gmail.com dart-lang/co19#1401. [Patterns] Constant pattern tests update according to the new spec (dart-lang/co19#1566)
2022-12-01 sgrekhov22@gmail.com dart-lang/co19#1401. [Patterns] Parenthesized pattern tests added (dart-lang/co19#1548)

Change-Id: I2458848da6ba816368c6d5b9bfe8d7fa6467dfcd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273360
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-12-05 08:41:02 +00:00
Jens Johansen b812517fac [analyzer] Don't ask for subtypes for the same elements several times when searching for references
When asking for all references of a member it starts by finding all
supertypes for the class, then for each supertype (including itself)
(that has a member with the same name as the one we're querying for)
it searches for all subtypes.

We recall that when getting all subtypes, it really gets all direct
subtypes, then for each of those, their direct subtypes etc.
Naturally, then, with getting all subtypes for all supertypes we
will often ask for all direct subtypes of the same class several times.

In fact, it's O(n^2):

As an example, if asking for references to `foo` on this
(in a file in analyzer, with 8 workspaces):
```
class X0 { void foo() { print('hello'); } }
class X1 extends X0 { void foo() { print('hello'); } }
class X2 extends X1 { void foo() { print('hello'); } }
[...]
class X149 extends X148 { void foo() { print('hello'); } }
```
we ask for subtypes 90600 (150 classes * 151 / 2 * 8 workspaces) times.

This CL stops that from happening and in the example from above we
"only" asks for subtypes 1200 (150 classes * 8 workspaces) times.

For the `newFile` from `AbstractSingleUnitTest` example, for instance,
we go from 28,264 asks to 17,432 asks (a ~38% reduction).

Non-first runtimes when asking for references:

Before:
0:00:03.074853
0:00:03.021881
0:00:03.034707
0:00:03.115596
0:00:03.032574

After:
0:00:02.223978
0:00:02.149937
0:00:02.150236
0:00:02.104704
0:00:02.175859

Difference at 95.0% confidence
        -0.894979 +/- 0.060283
        -29.2867% +/- 1.97266%
        (Student's t, pooled s = 0.0413338)

Change-Id: Id792a595e74de01c7186ab1263c38728f051f603
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272623
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-05 08:03:24 +00:00
Nicholas Shahan a464fc354b [ddc] Support more complicated subtype checks
Generate type hierarchy rules for all interface types used in a
module. These rules are utilized by the `isSubtype()` to determine
interface subtypes.

Issue: https://github.com/dart-lang/sdk/issues/48585
Change-Id: I63f64075d4947f234eca5e730ad15588e60b9e1e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266542
Reviewed-by: Anna Gringauze <annagrin@google.com>
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-12-03 00:37:41 +00:00
Nicholas Shahan bf548e788a [ddc] Clarify class vs type references for records
Preparation for separating type representation from classes.

Use `JS_CLASS_REF(_RecordImpl)` to inline a reference to the class
in JavaScript (not the type representation).

Use a standard Dart `is _RecordImpl` type test and let the compiler
produce the correct type test code.

Change-Id: I160312d61137ad0c6b2aa30b8aeba4acbe848df9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273523
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2022-12-03 00:26:58 +00:00
Paul Berry eb827958a4 Remove support for & and | in patterns.
Logical-and and logical-or patterns must now use `&&` and `||`,
respectively.

Change-Id: I87774016da46a21c90a50581e7ed843160159c80
Bug: https://github.com/dart-lang/language/issues/2501
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272743
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 23:53:40 +00:00
Brian Wilkerson 6346e7fcd1 Update imports in files other than the source and destination when moving declarations
Change-Id: I3675bddc9479744a4642bdbb66b8de013f0f01df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273524
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 23:22:16 +00:00
Konstantin Shcheglov 95a390cfd9 Don't report CASE_EXPRESSION_TYPE_IS_NOT_SWITCH_EXPRESSION_SUBTYPE when patterns is enabled.
Change-Id: I780ab9a9c82e115d254c61311ac8015f46db12aa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273540
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 22:57:21 +00:00
Konstantin Shcheglov 48d0d95edb Report CONSTANT_PATTERN_WITH_NON_CONSTANT_EXPRESSION
Change-Id: Idb6d0963515457e1748362dbda1441d5820a040a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273521
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 22:56:57 +00:00
Alexander Aprelev 4275d595b6 [vm/regexp] Copy, rather than share RegExp objects between isolates.
RegExp code objects keep backtracking and registers stacks in object pools, can't be shared between isolates.

BUG=https://github.com/dart-lang/sdk/issues/50082
TEST=one_regexp_many_workers

Change-Id: Ic7db8d7a75a0951178b2f4800f96224d52506545
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273480
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Aprelev <aam@google.com>
2022-12-02 22:45:21 +00:00
Kallen Tu 6c9873bf42 [cfe] Report error when using a class as a mixin when sealed-class is enabled.
From the changes in dart-lang/language#2674 that specify from a certain language version, we would like classes to not be used as mixins unless specified as a 'mixin class'.

Currently, this behaviour is under the sealed-class flag. May be subject to change as the other modifiers are added, but I'd at least like to make sure this works for sealed classes.

Change-Id: I5754b383327dde06d49175fe2d05c8ba7462145f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273082
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2022-12-02 22:31:58 +00:00
Konstantin Shcheglov 70b994e54f Test rest element with subpattern in map pattern.
Change-Id: I348ce8bfb6b32b3fcd1a63427d0a82a33dfa2c1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273520
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 21:50:50 +00:00
Nate Bosch b64f84d695 Mention late errors in Future.timeout doc
Add an example where the source future results in an error that is ignored, with
only the `TimeoutException` surfacing in a catch block.

Move some comments to the same line as the `print` call to match other
lines in the example code. Use doc comment syntax on functions in the
example code.

Change-Id: I5d3146ebe8f7edce303d76ff36822ced9b831c95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272960
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-12-02 20:05:26 +00:00
Joshua Litt b493cdfc1b [dart2wasm] Add runner script to streamline running wasm in d8.
Change-Id: I0f891d28419d0df55f94e0229ff33e87b791e7d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273280
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-12-02 19:55:16 +00:00
Devon Carew 72c5a1a900 [deps] rev collection, fixnum, http, protobuf, sse, stack_trace, test, webdev
Revisions updated by `dart tools/rev_sdk_deps.dart`.

collection (efd709f..caf6802):
  caf6802  2022-11-28  Nate Bosch  Tweak docs for split extensions (#256)

fixnum (bca3816..62916f2):
  62916f2  2022-11-24  Lasse R.H. Nielsen  Split into separate libraries instead of using parts. (#97)
  14d4827  2022-11-23  Lasse R.H. Nielsen  Add `tryParse` methods. (#96)

http (047d6ed..976bd56):
  976bd56  2022-11-28  Kevin Moore  Use latest mono_repo (#832)

protobuf (c181573..4f3e328):
  4f3e328  2022-11-30  Devon Carew  Emit imports in sorted order (#778)
  3cc088e  2022-11-28  Kevin Moore  Latest mono_repo (#779)

sse (8d018dd..d396145):
  d396145  2022-11-29  Elliott Brooks (she/her)  Fix Fetch credentials (#69)

stack_trace (dce0013..cf3562e):
  cf3562e  2022-12-01  Devon Carew  blast_repo fixes (#123)

test (b25dac9..f3d80a6):
  f3d80a68  2022-11-29  Nate Bosch  Fix missing label and reason after isNotNull (#1797)
  5b1f0075  2022-11-29  Nate Bosch  Use double quotes for test names on windows (#1802)
  986045c4  2022-11-29  Nate Bosch  Temporarily pin to ubuntu 20.04 (#1800)

webdev (637b406..91b8a19):
  91b8a19  2022-12-01  Elliott Brooks (she/her)  Fix global variable `isInternalBuild` in injected client (#1805)
  7d0810a  2022-11-30  Elliott Brooks (she/her)  Updates the `fixture` package `pubspecs` so it is clear what shouldn't be migrated to null-safety
(#1803)
  acd3f9f  2022-11-30  Elliott Brooks (she/her)  Can debug with the MV3 Dart Debug Extension (#1802)
  1258510  2022-11-29  Elliott Brooks (she/her)  Detect whether the Debug Extension was built for dev or release (#1800)
  b4a23c6  2022-11-29  Elliott Brooks (she/her)  Fix Fetch API implementation (#1801)
  67133df  2022-11-29  Elliott Brooks (she/her)  Pull out debug logging into one file (#1799)
  a395c68  2022-11-28  Elliott Brooks (she/her)  Handle detecting Dart app when tab changes (#1796)
  4fb4328  2022-11-28  Elliott Brooks (she/her)  Authenticate the user when they click on the Dart Debug Extension icon (#1795)

Change-Id: I7beeeb43de4ba514817836ffd4ff6a62b801f2dc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273282
Commit-Queue: Devon Carew <devoncarew@google.com>
Auto-Submit: Devon Carew <devoncarew@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 19:02:54 +00:00
Ryan Macnak ed2899ea4a [vm] Don't unroll initialization code based on macro lists.
-30k (-0.07%) out/ReleaseX64/exe.stripped/dart
-29k (-0.25%) out/ReleaseX64/exe.stripped/dart_precompiled_runtime

TEST=ci
Change-Id: I7c05705ada10dcaa388d9c8a8abd4edd9495cdc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273009
Reviewed-by: Alexander Aprelev <aam@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-02 18:45:03 +00:00
Ömer Sinan Ağacan a1a942f960 [kernel] Remove references to DispatchCategory
DispatchCategory was removed in 74cf86cb.

Change-Id: Id5fa7710d7cd68d6004360bee90ac342c5f90583
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273400
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-12-02 18:19:36 +00:00
Ryan Macnak 393451a37a [test_runner] Extend the --rr option to include run_vm_tests and gen_snapshot.
Change-Id: I3e1a950e9fb9d25bbade60c9fe3577e5dbcd6f78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272862
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Jonas Termansen <sortie@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-02 18:16:12 +00:00
Brian Wilkerson edb66fe3bb Capture the prefix for references in the search index, take 2
Change-Id: I600dd7c064ce9779251d043305becd4a8203bbc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271802
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 18:00:59 +00:00
Konstantin Shcheglov 46bffdabb1 Test logical-and in variable declaration, report REFUTABLE_PATTERN_IN_IRREFUTABLE_CONTEXT.
Change-Id: I7fcffea3b591fbe3a181a8bb8a8a461d18ec3d64
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273340
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 17:53:19 +00:00
Konstantin Shcheglov cdf5aa216e Fix rewrite tests after issue 50591 fixed.
Change-Id: Ic730d69ea5f6f309aa27e785b52d5f42d1186041
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273461
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 17:52:56 +00:00
Sam Rawlins 987c7503d1 Move DAS tutorial dir, and add light mode icons
The tutorial doc was mistakenly _not_ in the doc/ directory.

The icons show up as way too big, so I use inline HTML to specify
their width, so that they look good inline.

I add light mode icons, and use GitHub (and dartdoc)'s support for
switching between light mode and dark mode images.
https://www.stefanjudis.com/notes/how-to-define-dark-light-mode-images-in-github-markdown/

Change-Id: I1a368bfc6628adf941ba5e7a752317f9757d2538
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273460
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 17:16:08 +00:00
Ryan Macnak 16149782ef [test] Make less memory be gated by finalization in splay_dart_finalizer_test.dart.
When the heap limit is reached, directly unreachable objects are reclaimed but objects that will be unreachable after a finalization are not, and there needs to be enough headroom between opportunities for finalizers to run (returning to the event loop).

So only do the finalization thing with the upper, high-mutation part of the splay tree and remove it from the lower, write-once part. The high-mutation part is what's more interesting for GC stress testing.

Bug: https://github.com/dart-lang/sdk/issues/50597
Change-Id: Id02b38b0ac1e9bb640954ef1b686ce3eef8370af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273300
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2022-12-02 17:04:38 +00:00
Paul Berry e9a1248fc2 Add parser support for patterns in for-in statements and collection elements.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I9eda03c1501cf3164cfb09cf9084576a5d1141cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273122
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-02 15:22:38 +00:00
Jens Johansen ff87b5ea8e [CFE] Replace 'first' with 'roots'
Before we could get into a situation where we didn't produce the entire
class hierarchy when we loaded from dill even though we set up the
entry points correctly.
This might not be perfect, but seems better.

Change-Id: Ifc56930da7ccad52e96ae32d6a8ab509421b37b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273381
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-02 15:18:27 +00:00
Paul Berry c381425bd3 Parser: additional fixes to mayParseFunctionExpressions for patterns.
Expressions can also occur in patterns, either after an equality or
relational operator (e.g. `== e`), or after `const` (though what's
allowed after `const` is heavily restricted).  We need to make sure
that the expression parser doesn't greedily treat `=>` as introducing
a function expression when parsing these constructs inside a switch
expression.

But it's ok to allow function expressions inside list patterns, map
patterns, parenthesized patterns, and in the argument part of object
patterns.  (These will be rejected by a later stage of analysis
because expressions inside of patterns must be const, and a function
expression can't be const.  But the parser should still accept them so
that we can give useful error messages).

Fixes #50591.

Bug: https://github.com/dart-lang/sdk/issues/50591
Change-Id: I828555782f5bc8cb8aae8a3948849b7a75bdec57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273286
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-02 15:04:09 +00:00
Paul Berry 882941caf4 _fe_analyzer_shared: add support for rest patterns with subpatterns in maps.
The parser now handles maps that contain rest patterns with
subpatterns (e.g. `{'foo': _, ...var rest}`).  Even though this is
invalid Dart, it still makes sense for the parser to handle it so that
we can generate higher quality error messages.

The shared type analyzer now generates an error,
`restPatternWithSubPatternInMap`, if it encounters this error
condition.

Change-Id: I7f447bde28e646593aa432e3e5ad1f5e415bdd30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273283
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2022-12-02 13:50:38 +00:00
Johnni Winther 999c9b5e19 [cfe] Add (rudimentary) subtype implementation for ViewType
Change-Id: I7b102de842a828bb2c49b347d045d5919a4a5ae5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273241
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-12-02 11:17:34 +00:00
Jens Johansen 8cc984cd45 [analyzer] More timings and keep track of number of invocations
Before we might get something that looks like this:
```
(name: request, elapsed: 0:00:00.732983, elapsedSelf: 0:00:00.002428)
  (name: requireResolvedUnit, elapsed: 0:00:00.037635, elapsedSelf: 0:00:00.037635)
  (name: _getImplementations, elapsed: 0:00:00.692920, elapsedSelf: 0:00:00.000135)
    (name: searchAllSubtypes, elapsed: 0:00:00.691494, elapsedSelf: 0:00:00.691494)
    (name: filter and get location, elapsed: 0:00:00.001291, elapsedSelf: 0:00:00.001291)
```

With this CL we get this:
```
(name: request, count: 1, elapsed: 0:00:00.739592, elapsedSelf: 0:00:00.008764)
  (name: requireResolvedUnit, count: 1, elapsed: 0:00:00.104381, elapsedSelf: 0:00:00.104381)
  (name: _getImplementations, count: 1, elapsed: 0:00:00.626447, elapsedSelf: 0:00:00.000350)
    (name: searchAllSubtypes, count: 1, elapsed: 0:00:00.624650, elapsedSelf: 0:00:00.001226)
      (name: _searchDirectSubtypes, count: 428, elapsed: 0:00:00.623424, elapsedSelf: 0:00:00.023618)
        (name: discoverAvailableFiles, count: 8, elapsed: 0:00:00.000422, elapsedSelf: 0:00:00.000422)
        (name: subTypes, count: 3424, elapsed: 0:00:00.599384, elapsedSelf: 0:00:00.599384)
    (name: filter and get location, count: 1, elapsed: 0:00:00.001447, elapsedSelf: 0:00:00.001447)
```

Change-Id: Ia6ff3a55d7d0467b41a036ecdfb86f7e7b436b55
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272622
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-12-02 08:58:23 +00:00
Johnni Winther 8bda08227d [cfe] Handle access to 'this' and parameters in view instance methods
Change-Id: I033ba603cb9f289e3ab4b39977b68e0c4641c61b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273182
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-12-02 08:40:26 +00:00
Sam Rawlins 14d553ad9d Add a tutorial for collecting instrumentation, and analyzer diagnostics
Change-Id: Icdf8480cf9954b6181bed320ccc1764055bd6640
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273301
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-12-02 07:31:18 +00:00
Nate Biggs e48df2f7f3 [dart2js] Carry library load priorty through to script tag creation.
Change-Id: Ie05b5ffe0f2e1638faf8b784a2e8c5535ec0d76a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272760
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-12-02 05:19:53 +00:00
Konstantin Shcheglov 73721f7654 Report PATTERN_TYPE_MISMATCH_IN_IRREFUTABLE_CONTEXT
Mostly to don't crash when running co19 tests.

Change-Id: I62838d04872642b2e3a9ed01a1be120aec1c0608
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273081
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-12-02 02:58:16 +00:00
Nate Biggs 3daee0282b [dart2js] Fix inferrer bug in handling exit conditions in try/catch/finally.
This is showing up in places like here where we are inferring `JSObject.toString` to return `String?`:
https://github.com/dart-lang/sdk/blob/main/sdk/lib/_internal/js_runtime/lib/js_patch.dart#L204

Change-Id: Ie15c6a06cd1e0f9ead87b4a9ceaa949bdcbce989
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269040
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Nate Biggs <natebiggs@google.com>
2022-12-01 22:16:35 +00:00
Oleh Prypin 328c261397 Expand RemoveReturnedValue fix to turn => null into {}
This is targeted at the lint `avoid_returning_null_for_void` which already complains about expression function bodies but the fix doesn't do anything for them.

Change-Id: I14f3d7659301edae08482d9ffa6b72b483737e59
Bug: https://github.com/dart-lang/sdk/issues/45920
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272940
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
Commit-Queue: Oleh Prypin <oprypin@google.com>
2022-12-01 22:04:48 +00:00
Paul Berry 599911d197 Add parser support for for (var pattern = expression; ...; ...)
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I5f07b848ba06be403e56538a4cc64f6de51bd668
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273005
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-01 21:49:47 +00:00
Paul Berry 9221f34648 Update analyzer and CFE unit tests to use && and || in patterns.
In a follow-up CL I'll remove support for logical-and and logical-or
patterns using `&` and `|`.

Bug: https://github.com/dart-lang/language/issues/2501
Change-Id: I2627cd9999ac703dd0ab63cd6be3d0d883860674
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272920
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-12-01 19:41:43 +00:00
Paul Berry b0c705e4bd Set mayParseFunctionExpressions properly during switch expression parsing.
We need to prohibit function expressions during guard clauses in
switch expressions, otherwise the `=>` might be misinterpreted.

Fixes #50591.

Bug: https://github.com/dart-lang/sdk/issues/50591, https://github.com/dart-lang/language/issues/2672
Change-Id: Ie5703ac7049557798b19778281429e8a591cf09f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273020
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-12-01 18:57:33 +00:00