Commit graph

101738 commits

Author SHA1 Message Date
Elliott Brooks 22ae1db27f Update third_party gitignore so that package:dap is not gitignored during publishing.
Bug: https://github.com/dart-lang/pub/issues/4300
Change-Id: I0679d5425b90d454e6f2bd7e0de9d0aac9e84581
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370700
Commit-Queue: Elliott Brooks <elliottbrooks@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2024-06-11 16:30:26 +00:00
Ömer Sinan Ağacan 455d85f528 [dart2wasm] Port VM JSON parsing improvements
This ports https://dart-review.googlesource.com/c/sdk/+/365803 to dart2wasm.

Benchmarks: https://golem.corp.goog/Revision?repository=dart&revision=110551&patch=19222

Change-Id: Id4a8e0f44abcde3552c50605d9b329443d43d1d5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370821
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-06-11 16:10:23 +00:00
Ben Konyi d96ff605e2 [ CLI / DDS ] Close stderr for dart development-service after connection details have been printed
This will simplify logic in clients parsing this information by
providing a clear signal that all connection data has been sent over the
stream and is ready to be decoded.

Change-Id: Iae3779fe13662bf15187e9fa41febba94af4f2c7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370940
Commit-Queue: Ben Konyi <bkonyi@google.com>
Commit-Queue: Derek Xu <derekx@google.com>
Auto-Submit: Ben Konyi <bkonyi@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2024-06-11 16:06:47 +00:00
Ömer Sinan Ağacan efc59ee300 [vm/libs][dart2wasm] Add some missing type arguments to convert_patch List types
Tested: existing tests
Change-Id: Ib19748e947ef9a80852ef80f7726b5d1c987a26e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370920
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-06-11 15:03:49 +00:00
Danny Tuppeny b8cb98d0bb [dds/dap] Prevent duplicate values showing in variables views when a class has both a field and a getter with the same name
When a class contains both a field and getter with the same name, we'd include both in the `variables` response. In most cases these are the same value (although it's not guaranteed).

I've chosen to just hide the field in this case and always show the result from evaluating the getter (since I think that's what the user would expect, even in the case where they happen to have different values). Another option could be to show both (but change the name so that fields/getters are shown differently), however in that would change the display (for example adding `get ` in front of all getters) we should probably only do that if it's clear there is demand for it.

Fixes https://github.com/Dart-Code/Dart-Code/issues/5128

Change-Id: I9e23d22a844ee22c38988456b1f275422c5c9e04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370640
Reviewed-by: Ben Konyi <bkonyi@google.com>
Reviewed-by: Helin Shiah <helinx@google.com>
Commit-Queue: Ben Konyi <bkonyi@google.com>
2024-06-11 14:43:15 +00:00
Johnni Winther 2820e96b3c [cfe] Add repro/regeneration command to macro test
This prints the commands needed to reproduce or generate expectations
for the macro application test.

Change-Id: Idf62ec8d8bdc846d2b043328b447f51839984c48
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370883
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-06-11 14:11:22 +00:00
Ömer Sinan Ağacan e7d3b7820a [dart2wasm] Port VM JSON decoding improvements
This ports https://dart-review.googlesource.com/c/sdk/+/358445 to
dart2wasm.

The only difference from the VM patch is that we use `U8List` instead of
`Uint8List` for the chunk type in `_JsonUtf8Parser`, to avoid parsing
slow dart2wasm `Uint8List` subclasses (`JSUint8ArrayImpl`,
`_SlowU8List`).

Benchmarks: https://golem.corp.goog/Revision?repository=dart&revision=110551&patch=19217

Change-Id: I2af7131e72014587e97bab09e80e920c445b2c32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370820
Commit-Queue: Ömer Ağacan <omersa@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-06-11 13:41:20 +00:00
Ömer Sinan Ağacan 4796b25a30 Reland "[dart2wasm] Check import/export pragmas in user code"
This is a reland of commit 35bc17a0fa

Changes from the original CL is that we now allow packages in
`allowedInteropLibrariesInDart2WasmPackages`.

Original change's description:
> [dart2wasm] Check import/export pragmas in user code
>
> Change-Id: I926d108a4571d685c67d3a174a8e506910cce8f7
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369020
> Commit-Queue: Ömer Ağacan <omersa@google.com>
> Reviewed-by: Martin Kustermann <kustermann@google.com>

Change-Id: I69f61ecf246dfdbfcab372c6c2adb2a64f2d0b36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370900
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-06-11 13:12:27 +00:00
Jens Johansen 5a49a95b39 [CFE] add --updateExpectations to coverage suite
So running `pkg/front_end/test/coverage_suite.dart --updateExpectations`
will update `pkg/front_end/test/coverage_suite_expected.dart` and a `git
diff` will give an overview of what changed.

Also save both number of hits and number of misses in the
"expect-file". If nothing else it will give some context
about what has changed.

Also cleanup json coverage output to be sorted and not
include "misses" that are also "hits" (the VM can give
this information).

Change-Id: I426681dde3d4d2ad0a9a7dfa474292c699223d68
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370520
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-06-11 12:36:05 +00:00
Sigurd Meldgaard 4be693af0b Bump pub to df3664d17fd146ccd19b32820a022404da91f6d3
Changes:
```
> git log --format="%C(auto) %h %s" 6171682..df3664d
 https://dart.googlesource.com/pub.git/+/df3664d1 Reject overrides of workspace packages (4303)

```

Diff: https://dart.googlesource.com/pub.git/+/61716827b14e1848d82f1070ed5be881650c511d..df3664d17fd146ccd19b32820a022404da91f6d3/
Change-Id: I288c4cc3dc79028301872e26f6e8f664a3423e9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370801
Reviewed-by: Jonas Jensen <jonasfj@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2024-06-11 11:20:08 +00:00
pq 19c5914ce5 quick fix for COLON_IN_PLACE_OF_IN
See: https://github.com/dart-lang/sdk/issues/55917


Change-Id: I2dbe760dd0d123fc4b1bf493c8f7699baaea376c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370503
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-06-11 11:00:14 +00:00
Chloe Stefantsova 55a12750ec Reland [cfe] Account for compilation stage in invocations post-processing
Closes https://github.com/dart-lang/sdk/issues/55849
Closes https://github.com/dart-lang/sdk/issues/55755

This is a reland of https://dart-review.googlesource.com/c/sdk/+/369063

Change-Id: I9033935b3b352108c8c28b7ae09eaa9673b0a6fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370560
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2024-06-11 10:48:15 +00:00
pq fb3016a584 quick fix for INVALID_MODIFIER_ON_SETTER
See: https://github.com/dart-lang/sdk/issues/55917

Change-Id: Ieabdb7b9d12ef409d99497a32b6701a89c936434
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370481
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-06-11 09:28:47 +00:00
Martin Kustermann 847c35612a [dart2wasm] Make dart compile wasm compiled apps disable dart.library.ffi
This is a follow-up to [0]. That CL changed dart2wasm's modular
transformer to issue an error if `dart:ffi` is imported.

Users of packages that have specialized code for the VM (which supports
FFI) use conditional imports based on `dart.library.ffi`. We don't want
the VM-specific code to be used for web in dart2wasm (as dart2wasm
doesn't support the entirety of `dart:ffi`).

As a result we're going to make `dart.library.ffi` be false in
coditional imports (as well as in
`const bool.fromEnvironment('dart.library.ffi')`).

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

Issue https://github.com/dart-lang/sdk/issues/55948
Issue https://github.com/flutter/flutter/issues/149984

Change-Id: I70a775278ab701d1fd2596521e378cb6364edac2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370580
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2024-06-11 09:28:40 +00:00
Tess Strickland 324ba0c11f [vm/compiler] Extend Assembler::AddScaled to take a base register.
Add an additional base argument to Assembler::AddScaled so it now
computes:
  dest <- base + (index << scale) + offset

If base is kNoRegister (or ZR when available), then it emits
instructions optimized for computing:
  dest <- (index << scale) + offset
(i.e., its previous implementation)

Add AddScaled to AssemblerBase to ensure the same interface across all
architectures.

Rework the backend of CalculateElementAddress to use AddScaled
appropriately, which unifies it across architectures.

TEST=ci (refactoring)

Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-simarm_x64-try,vm-aot-linux-debug-simriscv64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-linux-debug-simriscv64-try,vm-mac-debug-arm64-try,vm-aot-mac-release-arm64-try
Change-Id: I33c8f99604b68360f10b79050bd66ceb9d65ac9b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370504
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2024-06-11 08:33:29 +00:00
pq 9544fe9641 [wildcards] local and parameter scopes
Update wildcard variable scopes.

See:  https://github.com/dart-lang/sdk/issues/55862 and https://github.com/dart-lang/sdk/issues/55680.

See discussion on related/ updated co19 test (`co19/LanguageFeatures/Wildcards/wildcards_do_not_shadow_A01_t04`) here: https://github.com/dart-lang/co19/issues/2698.





Change-Id: I388895ef7bac69617700504a964ce9f3021b2d24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368526
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-06-11 08:14:35 +00:00
pq 7ead4b5786 quick fix for MISSING_TYPEDEF_PARAMETERS
See: https://github.com/dart-lang/sdk/issues/55917

Change-Id: I9b81940c1c515bf923ceecb83d5aaad1d416dab1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370482
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-06-11 08:03:15 +00:00
Jens Johansen 49e0c0b33e [vm_service] Skip vm_service/test/coverage_closure_call_after_optimization_test.dart in aot (2nd try)
I by mistake added ".dart" in the status file in the first go, making it
not match.

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

Change-Id: Ibc0b9163b0a14766cf9cc6b43746f0bd6bc4ad90
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370800
Commit-Queue: Slava Egorov <vegorov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-06-11 06:58:24 +00:00
Brian Quinlan 33563e5cf9 [io,doc]: Point out that exit does not kill child processes.
Bug:https://github.com/dart-lang/sdk/issues/53772
Change-Id: I38d18e97036b5684982a78f44f03634c5b3dceea
CoreLibraryReviewExempt: documentation only
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370320
Commit-Queue: Brian Quinlan <bquinlan@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-06-10 22:58:28 +00:00
Alexander Markov 6ab01427bd [pkg/vm] Consolidate kernel compilation options to an object
TEST=ci

Change-Id: Ic9a8801bff140b1393decde61917e8c61ab1945d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370721
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-06-10 22:56:50 +00:00
Konstantin Shcheglov 31a4bb7f60 DevX. Issue 22915. Show instantiated type alias in diagnostics.
Bug: https://github.com/dart-lang/sdk/issues/22915
Change-Id: I733bcb6021a167825840027df371fd22cfc71ce3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370701
Reviewed-by: Sam Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2024-06-10 21:19:08 +00:00
Ryan Macnak ea9eb67d54 Roll Clang to 3809e20afc68d7d03821f0ec59b928dcf9befbf4.
Re-run clang-format.

TEST=ci
Change-Id: Ic277ea6baefa42bcc49ebce4f1099b910066cd4e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370680
Commit-Queue: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
2024-06-10 20:38:30 +00:00
pq 6cfe153e1e [wildcards] quick fix to convert UNUSED_LOCAL to wildcard
Fixes: https://github.com/dart-lang/sdk/issues/55965

Change-Id: I3585ce3823e0b7f7d2232611b27bb086b8b30d14
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370505
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-06-10 19:42:06 +00:00
Kallen Tu 141bb5417b [kernel] Add isWildcard flag to VariableDeclaration.
Adds the `isWildcard` flag to variables. Will be using this for producing better errors.

TEST= Existing expectations tests for wildcards pass with new flag.
Bug: https://github.com/dart-lang/sdk/issues/55655
Change-Id: If2f7a5555e7cc26e84d1b1e63e4261c81a157d78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370062
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2024-06-10 19:33:39 +00:00
Paul Berry 172bbe09cd Add type tracking to type inference logging.
This commit updates the type inference logging logic introduced in
https://dart-review.googlesource.com/c/sdk/+/369788 so that it
additionally tracks the context and static type for each inferred
expression.

Tracking the context for each expression is easy, since it is an input
to the type inference algorithm, passed in to each `visit` method of
`ResolverVisitor` through the named parameter `contextType`. However,
there were a few expression types for which the context type *wasn't*
passed in, because it wasn't used (for example
`ResolverVisitor.visitBooleanLiteral`, since boolean literals always
have the same meaning regardless of their context). `contextType`
parameters have been added to these `visit` methods for consistency
with the other expression visit methods, so that the type inference
log shows the context for all expressions, whether it makes a
difference to inference or not.

Tracking the static type for each expression is a little trickier,
since it's not an explicit output of the type inference algorithm, but
rather the static type of each expression is set as a side effect of
the type inference mechanism. To make things more tractable, the
`ExpressionImpl.staticType` field is made private, and instead of
setting it directly, the resolver must set it by either calling
`recordStaticType` or `setPseudoExpressionStaticType`. The former is
used when resolving a real expression; the latter is used for
situations where the analyzer assigns a static type to an AST node
even though that AST node isn't really serving as an expression
according to the official language specification. (For example, when
analyzing the method invocation `x.foo()`, the analyzer stores a
static type on the SimpleIdentifier `foo`, even though according to
the language spec, `foo` in this context actually isn't an expression
in its own right).

Splitting the code paths that set static types into `recordStaticType`
and `setPseudoExpressionStaticType` allows for the type inference
logging mechanism to check some useful invariants: it verifies that
every expression that the resolver visits is either assigned a static
type exactly once through a call to `recordStaticType`, or it's
determined to not be a true expression (and hence not assigned a
static type at all); I believe the latter happens mostly when
analyzing erroneous code, or when the resolver visitor is called upon
to assign a type to an identifier that's in a declaration context.

Change-Id: Icdf023d03fba3c87dbec3a72d00d0e9c7d1da5fa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370322
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2024-06-10 18:07:01 +00:00
Devon Carew 8e219fcd08 [deps] rev collection, convert, dartdoc, ecosystem, http, mime
Revisions updated by `dart tools/rev_sdk_deps.dart`.

collection (586a5e8..141d83a):
  141d83a  2024-06-07  Graciliano Monteiro Passos  `CanonicalizedMap`: added constructor `fromEntries`. (dart-lang/collection#347)

convert (302af1b..70940e3):
  70940e3  2024-06-10  Alex Li   Upper-cast the return type of the decoder (dart-lang/convert#99)

dartdoc (ddb8fb4..3decf1e):
  3decf1ed  2024-06-07  Sam Rawlins  Restrict validation of runtime renderer files to a single, target version of (dart-lang/dartdoc#3778)

ecosystem (bc25c0c..865b2c5):
  865b2c5  2024-06-07  Devon Carew  update docs and metadata for package:sdk_triage_bot (dart-lang/ecosystem#266)
  268b516  2024-06-06  Devon Carew  initial version of a sdk issue triage bot (dart-lang/ecosystem#264)

http (a3567f8..b522000):
  b522000  2024-06-08  Anikate De  fix inconsistent test server behavior (dart-lang/http#1227)

mime (8d2d559..4ca2f5e):
  4ca2f5e  2024-06-10  Sarah Zakarias  Add `topics` to `pubspec.yaml` (dart-lang/mime#126)

Change-Id: I6b6279a4ff0af5ba19cc3c4180389b949f48d623
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370660
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2024-06-10 17:50:50 +00:00
Alexander Markov 9a3ca8ffd4 [vm,dart2wasm,tfa] Support dynamic interface in TFA
TEST=pkg/vm/testcases/transformations/type_flow/transformer/dynamic_module_extendable.dart

Change-Id: I6ef43053d86b1a12259f1cb4d0b542c9519591f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370143
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-10 17:28:10 +00:00
dependabot[bot] 05d9e5bf37 Bump github/codeql-action from 3.25.7 to 3.25.8
Closes https://github.com/dart-lang/sdk/pull/55963

GitOrigin-RevId: 8619c27e49c9226b952d17082c04086c95cffc4b
Change-Id: I82da17f70dad04f3e17b37e7838ef5aae029b582
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370324
Reviewed-by: Alexander Thomas <athom@google.com>
2024-06-10 16:22:59 +00:00
Alexander Markov 17e12879fc Dynamic interface yaml file
TEST=pkg/vm/test/transformations/dynamic_interface_annotator_test.dart

Change-Id: Ib620a98b19067c51d913b499274bfed9aaa576f4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370065
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2024-06-10 16:09:54 +00:00
Paul Berry ef57b15de7 Analyzer: initial infrastructure for logging details of type inference.
This is the first in a planned series of commits that will give the
analyzer and the CFE the ability to instrument their type inference
functionality. The eventual goal is to have an easy way for developers
of the Dart SDK (and perhaps even curious customers) to supply some
code to the analyzer and/or CFE, and see a trace of the relevant type
inference events (e.g. when each statement, expression, pattern, or
collection element was type inferred, the context supplied to type
inference of each expression, the static type of each expression, the
steps involved in inferring generic type parameters, significant flow
analysis events, etc.).

For now, the only functionality that is implemented is to track when
the `ResolverVisitor` enters and exits each expression. This is done
by adding the null-aware calls
`inferenceLogWriter?.enterExpression(...)` and
`inferenceLogWriter?.exitExpression(...)` to each expression `visit`
method in the `ResolverVisitor`.

In normal operation, `inferenceLogWriter` returns `null`, so there is
no effect. But when type inference logging is active, this call
triggers information to be recorded in memory. This information can be
printed to standard output in two scenarios: (1) if the user requests
type inference logging (not yet implemented), or (2) if the type
inference logging mechanism detects that an important invariant has
not been satisfied (e.g. improper nesting of `enterExpression` and
`exitExpression` calls).

This mechanism of using null-aware calls for instrumentation is very
low overhead when inference logging is inactive; I've verified using
Golem that the overhead is well below the noise level of all our
benchmarks (this Golem run was done using a private branch in which
inference logging is more completely fleshed out, to try to provoke
the most overhead possible).  Details can be found here:
https://golem.corp.goog/Comparison?repository=dart#targetA%3Ddart-analysis-server%3BmachineTypeA%3Dlinux-x64%3BrevisionA%3D110445%3BpatchA%3Dpaulberry-inference_log%3BtargetB%3Ddart-analysis-server%3BmachineTypeB%3Dlinux-x64%3BrevisionB%3D110443%3BpatchB%3DNone

Note that the expression visit methods in `ResolverVisitor` are
invoked in two ways depending on the surrounding code: via the
abstract function `ExpressionImpl.resolveExpression` (when supplying a
context) and via the standard visitor mechanism (typically using
`AstNode.visitChildren`). So there is no single unique function
involved in all expression type inference. This means that in order to
fully instrument expression inference, every single expression visit
method in `ResolverVisitor` must call `enterExpression` and
`exitExpression`. It would be very easy to get this wrong, and forget
to instrument an important expression type.

Two mitigation strategies were used to reduce the risk of an
expression type getting forgotten. Firstly, the
`ResolverVisitor.dispatchExpression` method (which is a
frequently-used entry point for type inferring an expression) calls
`inferenceLogWriter?.assertExpressionWasRecorded` after visiting the
expression; this checks that `enterExpression` was properly
called. Secondly, each time `enterExpression` is called, the inference
logging mechanism looks through the ancestors in the AST, and checks
that `enterExpression` was also appropriately called for the innermost
enclosing expression.

To make sure that the analyzer really satisfies the invariants that
these checks are checking, the type inference logging mechanism is
turned on when assertions are enabled (but it is turned on in a way
where it only dumps to standard out if something goes wrong). This
ensures that the checks will be verified when running analyzer unit
tests on the trybots, but doesn't introduce any extra overhead the
production analyzer (beyond the null-aware calls mentioned earlier).

In follow-up commits I intend to add logic to do the following:
- Track the context and static type of each expression.
- Track type inference of statements, patterns, and collection
  elements.
- Track the computations involved in solving for generic type
  parameters.
- Add a command-line mechanism that developers of the Dart SDK can use
  to analyze some code with type inference logging enabled.

Change-Id: I9757bdd2b3cb996fc98b615d87991de16674e53b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369788
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-06-10 15:16:06 +00:00
Sam Rawlins eee06a5f8f linter: move constant_identifier_names tests
Change-Id: I3bc6b00a94536c94ee0f68cc7875d6a05d9b76d1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370420
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Sam Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2024-06-10 15:15:12 +00:00
pq 2ebde46492 quick fix for INVALID_USE_OF_COVARIANT
See: https://github.com/dart-lang/sdk/issues/55917

Change-Id: I9e7ad32fb3aaea28c31b6b29af4b2f1233cb9f78
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370360
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
2024-06-10 15:08:03 +00:00
pq adc59f66a4 quick fix for NULL_CHECK_ALWAYS_FAILS
See: https://github.com/dart-lang/sdk/issues/55917

Change-Id: Ic38b8a9e9717fc477394ea19bbb7173b2234d2f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370380
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-10 15:07:09 +00:00
pq 224d19ec06 [wildcards] avoid_unused_constructor_parameters wildcard test
Test to ensure that `avoid_unused_constructor_parameters` doesn't overreport in the presence of an unused wildcard param.

(Note that underscores are ignored pre-wildcards too and this ensures that that behavior is preserved too.)

Fixes: https://github.com/dart-lang/linter/issues/4995

Change-Id: I13ef73eb28cf2501ed292dd3c56c9933a8feefa9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370540
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-06-10 15:00:00 +00:00
Brian Wilkerson 7d7596fe3a Ensure we have a matcher score for every suggestion
Change-Id: I1b2ae695deeaec05d11ca40d1367883667e4fee0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370300
Reviewed-by: Keerti Parthasarathy <keertip@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2024-06-10 14:59:04 +00:00
Keerti Parthasarathy 5e595d3374 Add a validator for pubspec.yaml workspace field.
BUG: https://github.com/dart-lang/sdk/issues/55915

Change-Id: I42dc1e2986a55a8e0ee0505cbfa6b3e2dbcbca85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370066
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Keerti Parthasarathy <keertip@google.com>
2024-06-10 14:46:20 +00:00
Sam Rawlins 38e60413a0 linter: move tests for three rules
* library_prefixes
* no_leading_underscores_for_library_prefixes
* package_prefixed_library_names

Change-Id: I641a547d572abc5001d42ceaed0dd216e0d07338
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370460
Auto-Submit: Sam Rawlins <srawlins@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2024-06-10 14:33:07 +00:00
Martin Kustermann e18c43a21e [dart2wasm] Add dart2wasm-asserts-* configurations
Our tests (including code in core libraries) are never run with
assertions enabled.

=> Add the necessary configuration support in test_matrix.json
=> We'll then add a new builder running one configuration with asserts.

Change-Id: Id1bc27ddf7d683846510af4711679ad14f0e4168
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370620
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-10 14:24:12 +00:00
Jens Johansen 2645665183 [vm_service] Skip vm_service/test/coverage_closure_call_after_optimization_test.dart in aot
Change-Id: I03e8445064b54ec2f9b19b0440b691e6835fab83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370600
Commit-Queue: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-06-10 13:46:25 +00:00
Johnni Winther b6249b851f [cfe] Introduce compilation unit
This adds CompilationUnit as a supertype of LibraryBuilder as a
first step towards splitting libraries from compilation units.
The SourceLoader._builders are now compilation units and lookups
in to the SourceLoader are split into compilation units, loaded
library builders and source library builders.

Change-Id: If9958a5a67443170cc1a538106d9efd424e36889
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369643
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-06-10 13:41:24 +00:00
Jens Johansen 911b8d11a7 [vm] RecordCoverageInstr isn't dead code
Dead Code Elimination can remove `RecordCoverageInstr`, but shouldn't.
This CL makes it stay by returning true in `HasUnknownSideEffects`
making `MayHaveVisibleEffect` return true, making Dead Code Elimination
keep it.
Note that `RecordCoverageInstr::Canonicalize` will still let it go away
if the position is already covered which is what we want.

Bug: https://github.com/dart-lang/sdk/issues/42061

TEST=pkg/vm_service/test/coverage_closure_call_after_optimization_test.dart,vm/cc/IL_RecordCoverageSurvivesOptimizations

Change-Id: Ifd72f9071a51924fd71f3dae91687acb1467047d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370220
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-06-10 13:02:28 +00:00
Martin Kustermann e7239ff03c [dart2wasm] Specialize is/as checks for interface types
Currently if we have a `<obj> is/as Iterable<T>` check we will

  * allocate a `WasmArray<_Type>` array and put value for `T` in it
  * allocate a `_InterfaceType` object with the array as type arguments
  * call to RTT which is looping over the type arguments array

With this CL we recognize in the compiler if we generate tests against
interface types and specialize the most common cases (0, 1 or 2 type
arguments). This in return will make us

  * call to 0/1/2 specialized RTT isInterfaceSubtype implementation
    which will use unrolled loops to do the checking.

=> We avoid allocation of `_InterfaceType` always
=> We avoid allocation of `WasmArray<_Type>` for length=0/1/2
=> We have faster checking due to unrolled loops.

(It is very unlikely binaryen can achieve the same, as it would
need to do very aggressive inlining & loop unrolling to get to the
same result. If we'd force it to inline then every is/as check
would be very large).

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

Change-Id: Ia99548d514683f678178ea30d07aeb742ae914ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370260
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-10 11:27:51 +00:00
Martin Kustermann 54ab47ec82 [dart2wasm] Refactor RTT type checking implementation
We make the compiler emit a special index (namely 0) into the
canonical type argument substitution table iff no substitution has to be
performed.

This is very common:

    ```
    class List<T> implements Iterable<T> {}
    ```

=> The translation of the type arguments from `List` to those of
   `Iterable` is a NOP and can therefore be skipped.

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

Change-Id: I16ad8d7196656dddeba15801e80c2e23ae0af51b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370242
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2024-06-10 10:49:58 +00:00
Sigurd Meldgaard efa782d1ba Bump pub to 61716827b14e1848d82f1070ed5be881650c511d
Changes:
```
> git log --format="%C(auto) %h %s" 75ab224..6171682
 https://dart.googlesource.com/pub.git/+/61716827 Bump actions/checkout from 4.1.5 to 4.1.6 in the github-actions group (4298)
 https://dart.googlesource.com/pub.git/+/0ecaae85 Handle whole workspace in dependency_services (4294)
 https://dart.googlesource.com/pub.git/+/bde31408 Avoid quoting null constraint (4293)
 https://dart.googlesource.com/pub.git/+/ddaf829c Remove a stale statement in a doc comment (4292)
 https://dart.googlesource.com/pub.git/+/61aea102 await exit code in publication test (4289)
 https://dart.googlesource.com/pub.git/+/4287a77c Also use absolute path in solve report, when root is a parent (4287)
 https://dart.googlesource.com/pub.git/+/d165b5fa Handle file system error 17 (EEXIST) on linux and macos (4286)
 https://dart.googlesource.com/pub.git/+/e48f9797 Include all directories in published tar.gz archive (4283)
 https://dart.googlesource.com/pub.git/+/2dd60e10 Test that consuming packages out of their workspace context works (4282)
 https://dart.googlesource.com/pub.git/+/d67d08e7 Test publishing from workspace (4280)
 https://dart.googlesource.com/pub.git/+/c9563e3c Include empty directories in published archives (4278)

```

Diff: https://dart.googlesource.com/pub.git/+/75ab224376e80e918d3c53494a36d4bf8a2f2af6..61716827b14e1848d82f1070ed5be881650c511d/
Change-Id: I679f2f4229c28970d33774eea17c08263abc3879
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370502
Reviewed-by: Sarah Zakarias <zarah@google.com>
Commit-Queue: Sigurd Meldgaard <sigurdm@google.com>
2024-06-10 10:34:42 +00:00
Sarah Zakarias 5e76f788a5 [pkg:meta] Add topics to pubspec.yaml
Closes https://github.com/dart-lang/sdk/pull/55923

GitOrigin-RevId: e4322c06820f99013464cc37dfa291f345aad686
Change-Id: I6bb9e7c9c6c2d8c823d49c098acf4c62fd2181b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369528
Commit-Queue: Sarah Zakarias <zarah@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-06-10 10:27:36 +00:00
Chloe Stefantsova d34dbe232a Revert "[cfe] Account for compilation stage in invocations post-processing"
This reverts commit d31d0f9618.

Reason for revert: The CL breaks some tests in google3.

Original change's description:
> [cfe] Account for compilation stage in invocations post-processing
>
> Closes https://github.com/dart-lang/sdk/issues/55849
> Closes https://github.com/dart-lang/sdk/issues/55755
>
> Change-Id: I471830cafed76ec5c503fe726ade857c007ed712
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369063
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>

Change-Id: Ia0fa3002a46352b15f42166188c32821897841ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370480
Reviewed-by: Slava Egorov <vegorov@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2024-06-10 09:13:59 +00:00
Martin Kustermann d32e2ece05 [dart2wasm] Move StackTrace.current for as checks into shared runtime code
When an implicit or explicit `as` check fails we throw a [TypeError]
exception with a stack trace. Though that stack trace doesn't really
have to have the top-frame being where the check failed, it's fine if
there's an additional frame from the runtime code that actually throws
the exception.

Doing so removes `StackTrace.current` from every `as` check and
therefore reduces size.

Change-Id: Ia34b59ebaa54b8cdcd2dc7b153a1e4e2fe1dd0e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370340
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-10 07:11:05 +00:00
Martin Kustermann 1e607007cd [dart2wasm] Optimize RTT data structures
This CL optimizes the RTT data structures by

* Having a canonical table for substitution arrays
* Stores the (canonical) substitution index to use right next
  to the super class id, thereby
* Removing an indirection when looking up substitutions

See more information in `sdk/lib/_internal/wasm/lib/type.dart`

This reduces
  * `Hello.Compile.Size.wasm.opt` by ~ 4%
  * `FluteComplex.Compile.Size.wasm.opt` by ~0.5%

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

Change-Id: If0a50780a9a604886bd67a08a2f345103f0bcb32
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369641
Reviewed-by: Ömer Ağacan <omersa@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-08 20:07:36 +00:00
pq 6424397cbf quick fix for STATIC_OPERATOR
See: https://github.com/dart-lang/sdk/issues/55917

Change-Id: I41dd40a11e98340dc90f3673c8c6b37e3bf3d7f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370161
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-06-08 19:57:46 +00:00
Martin Kustermann dd89732126 [dart2wasm] Make implicit arguments check use optimized is/as helpers
The implicit covariance type checks are currently performed by always
calling out to RTT. Those can use our existing optimized implementation
for is/as checks.

This reduces code size of -O2 mode as well as makes certain
benchmarks significantly faster (e.g. UIMatrix* 2x faster)

Change-Id: Ib5224a310b2188b9edb2de1e800d2e60010d11f1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/370280
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Martin Kustermann <kustermann@google.com>
2024-06-08 10:29:25 +00:00