Commit Graph

518 Commits

Author SHA1 Message Date
Johnni Winther fa2e23b83c [cfe][InternalNodes] Remove unused precise messages
These messages where never used. This was revealed through the separation of Variable and InternalVariable.

Change-Id: I96d337f941d300cc5437c9fa5c9341abe4889176
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/510380
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2026-06-10 00:27:50 -07:00
Johnni Winther 6a6f59f715 [cfe][InternalNodes] Move for-in lowering to inference visitor
This adds internal nodes for the encoding of various versions of for-in loops and moves the lowering to be performed as part of the inference. This avoids the need to create lowered and external AST nodes directly during body building.

Change-Id: If559bc19ff9e6aacb457413c71956c18eae2a4b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/499542
Reviewed-by: Paul Berry <paulberry@google.com>
2026-05-07 00:15:24 -07:00
Erik Ernst e05ce41c0d Add anonymous => method related implementation in the CFE
This CL adds an implementation of anonymous `=>` methods in the CFE
which is sufficiently complete to handle the existing test cases in
language/anonymous_methods/expression.

Coverage is handled by adding magic comments to ignore the fact that new
code is not covered by existing testcases. This will be settled in a
separate CL.

To keep the failures visible, the failures in configurations
dart2js-hostasserts-linux-d8-try, dart2js-linux-chrome-try,
dart2js-minified-linux-d8-try, and ddc-linux-chrome-try have not been
approved. It seems likely to me that those are bugs in dart2js and in
DDC.

Change-Id: Ia70fedd4de6166d6a3bf8a108f49728b6e16c9f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494440
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-04-21 02:09:41 -07:00
Sigmund Cherem 2540a8fae5 [cfe,dyn_modules] add dynamically-callable section to dynamic interface
This introduces the `dynamically-callable` section in the dynamic
interface and adds an initial, but incomplete, validation pass for it.

The current validator:
* Checks that dynamic calls use a selector that matches one of the
  exposed members in the `dynamically-callable` section.
* Validates that subtypes of `dynamically-callable` classes
  added in a dynamic module don't overlap with classes
  implementing `noSuchMethod`.

Note that the latter check is incomplete. Additional checks need to be
added when building the host app to reject subtypes defined in the host.

Future changes:
* validate during host compilation about other subtypes
* move validation for classes exposed in the dynamic interface to be done while compiling the host
* reject mixin methods that contain dynamic calls during host compilation.
* accept providing an allow list of valid selectors during compilation of dynamic modules, so it module-to-module calls are supported too.

TEST=CFE unit tests

Change-Id: I8d12192ef374c34a48fbdf2ba5002d2850ce926f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494001
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
2026-04-14 17:16:33 -07:00
Johnni Winther 24e1e1feea [parser][cfe][Augmentations] Remove support for augment super
This removes the remaining support for `augment super` in the parser, analyzer and CFE.

`augment super` will not be part of the augmentations feature.

Change-Id: Ie8a185bba067ab6ecf3b3229ecc20d5c284842bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/493401
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-04-08 03:07:32 -07:00
Sigmund Cherem 354b0f8606 [dyn_modules] Support types in a dynamic interface.
This CL adds a new `can-be-used-as-type` section in the dynamic
interface to expose the type of a class or extension type, without
making them callable or exposing their members.

Details:
* add the new section to the documentation
* add support in the TFA transformation to annotate kernel nodes
* add support to the validator to check for proper usage from dynamic modules
* add CFE, transformation, and end2end tests.

The CL ignores DDC and Dart2wasm at the moment and we intend to approve
any failures. It's possible that DDC works due to its modular nature.

BUG=b/488343137
TEST=cfe, annotator, and e2e tests

Change-Id: I900b22b85950f8ac379eabaa2ef58f075e18519c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/486340
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2026-03-12 09:46:50 -07:00
Daco Harkes dc07f70956 [record_use] Const instance recording classes must be final
And they may not be extended, implemented and mixed in.

It would be cleaner if we test the static checks with the [cfe]
test expectations. However, those test suites are not set up to
run from a package context, which `@RecordUse` annotations must be.

TEST=pkg/compiler/test/record_use/record_use_test.dart
TEST=pkg/dart2wasm/test/record_use_test.dart
TEST=pkg/vm/test/transformations/record_use_test.dart

Change-Id: Ia4e93a6f25ad4c246503ebf8ece67e7d4bca1410
Cq-Include-Trybots: luci.dart.try:dart2wasm-asserts-linux-chrome-try,dart2wasm-asserts-minified-linux-d8-try,dart2wasm-linux-chrome-try,dart2wasm-linux-d8-try,dart2wasm-linux-firefox-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-try,pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart2js-canary-linux-try,dart2js-hostasserts-linux-d8-try,dart2js-linux-chrome-try,dart2js-linux-firefox-try,dart2js-mac-chrome-try,dart2js-mac-safari-try,dart2js-minified-csp-linux-chrome-try,dart2js-minified-linux-d8-try,dart2js-unit-linux-x64-release-try,dart2js-win-chrome-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/482220
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Reviewed-by: Michael Goderbauer <goderbauer@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-02-23 04:15:43 -08:00
Daco Harkes 1cab2a8617 [record_use] Only record definitions with a package: uri
Record only for definitions in libraries with a `package:` uri.

* Converts all the tests to be in packages.
  * Bonus: This removes the uri-mapping in equality checks.
  * These packages are added to the root pub workspace.
  * For the dart2js tests we need to do some juggling to keep the
    tests files in memory.
* Only support `package:` uris
  * Removed all the `relativizeUri` code for file paths.
  * Start emitting errors on non `package:` uris with a `@RecordUse()`
    annotation.

Unrelated cleanups:

* We no longer support recording const instances in annotations, this
  PR cleans up code in `kernel` and `type_flow`.

TEST=pkg/compiler/test/record_use/record_use_test.dart
TEST=pkg/dart2wasm/test/record_use_test.dart
TEST=pkg/vm/test/transformations/record_use_test.dart

Closes: https://github.com/dart-lang/native/issues/2891
Change-Id: I1bc6905291230375e185930d2c000700ac778f85
Cq-Include-Trybots: luci.dart.try:dart2wasm-asserts-linux-chrome-try,dart2wasm-asserts-minified-linux-d8-try,dart2wasm-linux-chrome-try,dart2wasm-linux-d8-try,dart2wasm-linux-firefox-try,dart2wasm-linux-jscm-chrome-try,dart2wasm-linux-optimized-jsc-try,pkg-linux-debug-try,pkg-linux-release-arm64-try,pkg-linux-release-try,pkg-mac-release-arm64-try,pkg-mac-release-try,pkg-win-release-arm64-try,pkg-win-release-try,dart2js-canary-linux-try,dart2js-hostasserts-linux-d8-try,dart2js-linux-chrome-try,dart2js-linux-firefox-try,dart2js-mac-chrome-try,dart2js-mac-safari-try,dart2js-minified-csp-linux-chrome-try,dart2js-minified-linux-d8-try,dart2js-unit-linux-x64-release-try,dart2js-win-chrome-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/478920
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2026-02-06 09:27:13 -08:00
Erik Ernst 5d38f82c5f Add a few elements of the anonymous method implementation
This CL adds some elements of the implementation of anonymous methods:
- _fe.../messages.yaml: Add error message about wrong parameter list.
- analysis_server/.../error_fix_status.yaml: Add status of above error.
- analyzer/.../src/.../ast.dart: Add new AST classes AnonymousArrowBody
  AnonymousBlockBody, AnonymousMethodBody, AnonymousMethodInvocation.
- analyzer/.../to_source_visitor.dart: Add new `visit` methods.
- analyzer/.../ast_builder.dart: add `endAnonymousMethodInvocation`.
- analyzer/.../resolver.dart: add new `visit` methods.

Change-Id: Ifa562c653f608884319ad9a1d87e169d9fac4b75
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/475043
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2026-02-06 00:27:02 -08:00
Simon Binder 7d8cd032dc [dart2wasm] Interfaces for accessing memories
This adds the `Memory` class to `dart:_wasm`, allowing Dart code to
load and store numeric types in linear memory.
Since `dart2wasm` doesn't generate a memory instance by default, there
is no singleton instance of `Memory`. Instead, memories are defined as
`external` top-level getters annotated with a pragma like
`@pragma('wasm:memory-tyype', MemoryType(limits: Limits(1, 10)))` to
declare their type.

Interop happens in a static way: Methods on `Memory` cannot be torn-off
and, since the target memory is encoded directly in the store/load
instruction, there's also no polymorphism for memories in Dart.
Attempting to call methods on a memory instance that isn't a direct
reference to its definition is a compile-time error.

Memories can also be imported and exported through the existing
`wasm:import` and `wasm:export` pragmas.

TEST=tests/web/wasm/memory_test.dart

Change-Id: I726f33ac2ec04afab55c5a2b6bc09079d0193e02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/470020
Commit-Queue: Martin Kustermann <kustermann@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2026-01-15 03:45:21 -08:00
Erik Ernst 02641c88d0 Transfer parser updates of CL449821 into this CL
Specification proposal:
https://github.com/dart-lang/language/blob/main/working/0260-anonymous-methods/feature-specification.md.

Change-Id: I57743ec663633a148087c1be36e492e1e45e406e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464704
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Erik Ernst <eernst@google.com>
2025-12-04 08:03:41 -08:00
Robert Nystrom 5baa00aec9 [private named parameters] Report collision between public name and other parameters in CFE.
Change-Id: I4a3260b3bc280b6a7fb202c16e2b1ee862bfc018
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/465461
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2025-12-02 11:24:12 -08:00
Robert Nystrom ec64f62a7a [private-named-parameters] Report errors if the private name has no public name.
Eventually, the analyzer and front end will need to use the
corresponding public name as the effective name of the parameter. That
means that in addition to seeing if the parameter has a public name or
not, we actually need it. Instead of calculating the public name in the
parser and then plumbing it through the formal parameter listener, I
did the error reporting separately in the front end and analyzer.

Let me know if you think that makes sense. I can also move the other
private named parameters (back) out of the parser and into the two
front ends to be consistent if you want.

Change-Id: I9ca6c003b962d9b14d8dfa46eea4b31689935f04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/458703
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
2025-11-03 14:42:55 -08:00
Robert Nystrom 16e1a5be13 [private named parameters] Update compile errors
Change how the parser reports errors for named parameters that start with `_` in anticipation of supporting private named parameters.

With "private named parameters" some private named parameters are errors and some aren't. It's still an error to have a private named parameter that doesn't refer to a field. This updates the error reporting to implement that. It also consolidates the error reporting into the parser. Prior to this CL, analyzer would discard the parser's private named parameter errors and then re-detect and report them itself.

The errors you get now when the experiment is off are:

* If the parameter doesn't refer to a field, you get the old error that you can't have a private named parameter.

* If the parameter does refer to a field, you get an error telling you to enable the experiment. When the experiment ships, this changes to an error about updating the library's language version.

And when the experiment is on:

* If the parameter doesn't refer to a field, you get a new error that you can't have a private named parameter unless it refers to a field.

* If the parameter does refer to a field, it reports no error. It doesn't actually support private named parameters that refer to fields yet.

Let me know what I got wrong. It was a little tricky to figure out how it should behave when the experiment is off. One option is to have no user-visible changes in behavior at all when the experiment is off. So the feature is fully hidden behind the experiment.

But most other code I saw seems to take an approach where if the feature is off, it acknowledges the existence of the feature but tells the user it's disabled. I went with this approach but I don't know if that's something we should only do when it's closer to shipping.

Change-Id: I0fc4e9b06c8e7f0abc868e0f49d2b3e625c8dade
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456540
Auto-Submit: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
2025-10-27 14:15:37 -07:00
Mayank Patke a63045d197 [dart2wasm] Remove dart:js_util from supported libraries
Since that stops `dart:_js_annotations` from building on dart2wasm,
let's stop supporting that, too.

This causes `package:js` to no longer work on dart2wasm, but none of the
allowlisted packages use it any longer, so we can simply migrate tests
off of it.

Fixes: #56502
Fixes: #61550
Change-Id: I6a6a696438255ebf25a5a17131cdbd327ba81581
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453645
Commit-Queue: Mayank Patke <fishythefish@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2025-10-15 15:38:35 -07:00
Paul Berry 0677dc14cf [messages] Replace remaining CFE analyzerCode values.
Replaces the remaining `analyzerCode: FOO` entries in
`pkg/_fe_analyzer_shared/messages.yaml` with `psuedoSharedCode: FOO`
entries. A `pseudoSharedCode` entry carries two pieces of information:
it indicates that the error code is "pseudo-shared" (meaning that
there is manually maintained logic that translates it from a CFE
diagnostic to an analyzer diagnostic), and it provides an enum value
that can be used by the manually maintained logic to identify which
analyzer error to translate to.

In the few cases where diagnostic had a `pseudoShared: true`
annotation but no `analyzerCode`, a fresh `pseudoSharedCode` is
introduced.

The diagnostic code generation logic is updated accordingly. The logic
that translates CFE diagnostics to analyzer diagnostics is also
updated.

This change carries two benefits:

- It more accurately reflects reality; calling these codes
  `analyzerCode` was inaccurate because there was no automated process
  to verify that they corresponded to actual analyzer error codes, and
  in fact in many cases they didn't.

- It avoids confusion with the `analyzerCode` values in
  `pkg/_fe_analyzer_shared/messages.yaml`, which _do_ in fact
  correspond to actual analyzer error codes.

Change-Id: I6a6a69640fe4b04da0296086d052be46126a1ebd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453102
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-03 10:32:04 -07:00
Paul Berry 4ad8eafe24 [messages] Remove unused analyzerCode values.
Removes most of the analyzerCode values in
`pkg/front_end/messages.yaml`. The only ones that remain are those
associated with diagnostics marked `pseudoShared: true`; they are the
only ones whose values actually had an effect on generated code.

The removed analyzerCode values were of little value, since they
didn't have any effect and there were no tests to keep them
synchronized with actual analyzer error codes. In many cases, these
values did not even match any existing analyzer error code.

Removing these unused values will make it easier to make follow-on
improvements to the existing analyzerCode values, which do have a
functional effect.

Change-Id: I6a6a6964c93a0fd0b9cf48adbcda814e5f7eb178
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452884
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-02 12:38:32 -07:00
Paul Berry 6924418203 [analyzer] Fix translation of Encoding errors.
Adds a translation of the scanner error code `Encoding` to the
`translateErrorToken` function. Previously, this error was unhandled,
so if the scanner encountered invalid unicode, the analyzer would
crash.

Change-Id: I6a6a696433016dddd2cbc0660922ea5248d54419
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452901
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-10-01 11:42:31 -07:00
Johnni Winther 1d2b1553bc [cfe] Report error on part with library directive
Change-Id: Idad4b5a49a07be23a9a1df8390e3d216ff6539ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452420
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-10-01 01:59:31 -07:00
Johnni Winther 07de5c9fd8 [cfe] Report error on part-of with library name
Part-of directive can no longer use library names with the enhanced parts feature.

Change-Id: I8aa930f23fbc6c84be365e13e354def323e1c4b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/452100
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-09-29 05:20:30 -07:00
Srujan Gaddam 32f1db06cd [dart:js_interop] Add missing checks for toJSCaptureThis
Fixes https://github.com/dart-lang/sdk/issues/61439

These checks exist for toJS but were not added when we
introduced toJSCaptureThis. Error wording is slightly
modified to be consistent.

Change-Id: I12c861aacecc2bfed255be9f26c99bf2f1c02ebd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/449661
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Ömer Ağacan <omersa@google.com>
2025-09-16 10:30:21 -07:00
Paul Berry 6d6a629592 [messages] Move shared diagnostics to pkg/_fe_analyzer_shared.
Moves all the diagnostics that are shared between the analyzer and the
CFE from `pkg/front_end/messages.yaml` to
`pkg/_fe_analyzer_shared/messages.yaml`.

This CL was generated by the following steps:

- Run the `move_shared_diagnostics.dart` script introduced in
  https://dart-review.googlesource.com/c/sdk/+/448606.

- Manually modify `pkg/front_end/messages.status` to reflect the
  diagnostics that have been moved.

Change-Id: I6a6a6964d618089f8fe8d447b4344800bad5d532
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-09-15 07:21:42 -07:00
Paul Berry b32ef34b9a [messages] Prepare to add shared messages.yaml file.
Updates the code in `pkg/analyzer_utilities/lib/messages.dart` to
attempt to read CFE messages from both
`pkg/_fe_analyzer_shared/messages.yaml` and
`pkg/front_end/messages.yaml`, and updates clients accordingly.

Also updates the `messages_suite.dart` test and the presubmit rules to
ensure that the contents of `pkg/_fe_analyzer_shared/messages.yaml`
will be appropriately tested.

Since the file `pkg/_fe_analyzer_shared/messages.yaml` doesn't exist
yet, temporaryhacks have been added to pretend the file is empty if it
can't be found.

In a follow-up CL, I will move messages that are shared between the
analyzer and the CFE to `pkg/_fe_analyzer_shared/messages.yaml`.

Change-Id: I6a6a6964c1c02f20df9ae8e34f23e734bbe88c22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/448605
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-09-15 06:17:03 -07:00
Jens Johansen 080af85987 [CFE] Specific error message when using unavailable variables in expression evaluation
So instead of either being told that a variable doesn't exist, or
using a field or something instead of a local, you'll now get a message
saying "<variable> is unavailable in this expression evaluation".

Bug: https://github.com/dart-lang/sdk/issues/53996
Bug: https://github.com/dart-lang/sdk/issues/53087
Bug: https://github.com/dart-lang/sdk/issues/45913 (sort of?)
Bug: https://github.com/dart-lang/sdk/issues/53688
Change-Id: I6726209584e414ddc40f3e7ff6bffa9e7283e9d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445701
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-08-20 23:13:11 -07:00
Jens Johansen cf8cb78270 [cfe/shared] Polish messages_suite; add more examples to messages.yaml
* No more "Fail" status in messages.status.
 * Removed unused messages.
 * Added examples for (almost?) all messages where it's possible.
 * Add messages suite to coverage suite and update coverage.

== Additional notes

=== From the yaml spec (https://yaml.org/spec/1.2.2/)

```
2.3. Scalars
Scalar content can be written in block notation, using a literal style (indicated by “|”) where all line breaks are significant. Alternatively, they can be written with the folded style (denoted by “>”) where each line break is folded to a space unless it ends an empty or a more-indented line.
```

So we should probably use `|` and not `>` for code (especially if starting with a comment line (e.g. `// @dart=3.1`)) - and the other way around for messages.

=== These three settings

```
exampleAllowOtherCodes: true
exampleAllowMultipleReports: true
includeErrorContext: true
```

(or some combination of them)
closes https://github.com/dart-lang/sdk/issues/53634.

(one already existed, but was renamed)

Change-Id: I91a8ecee88d0600015252e289b068f60b1d1aeeb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/444600
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-08-14 07:26:23 -07:00
Chloe Stefantsova 6fa858cfe8 Enable 'getter-setter-error' flag in 3.9
TEST=existing

Change-Id: Ic4a5735adda7cf8ef1565b9356ca277d9b62b064
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/430720
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2025-05-26 08:08:31 -07:00
Alexander Markov f75a80392e [dynamic modules] Fix dynamic interface validation of extension types
Instead of validating the erasure of an extension type,
validate that extension type declaration and type arguments
are specified as callable.

TEST=pkg/dynamic_modules/test/data/extension_type2

Fixes b/411433443

Change-Id: I063f0a622abd0d75594c4095573b29a7888f5afb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423882
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2025-04-24 07:58:33 -07:00
Kallen Tu af51a0210b [cfe] Disallow '.new<int>' and type parameters on constructors for dot shorthands.
Adds errors for this part of the spec behaviour: `.new<typeArgs> and .new<typeArgs>(args) will always be compile-time errors because .new denotes a constructor which is not generic`

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I76074d2314f40f60015324d4b01ece7477a8ffb4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-27 12:15:57 -07:00
Kallen Tu ab778ef480 [cfe] Dot shorthands - Errors for invocations.
Adds `DotShorthandsUndefinedInvocation` error to handle unresolved method or constructor invocations.

Updates test expectations.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I004f989e2d6f460892964106ad72861fd3e49a5c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/417084
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-03-25 08:28:24 -07:00
Kallen Tu caa192d24c [cfe] Dot Shorthands - Errors for getters and fields.
This CL adds two errors - 1 for having an invalid context type for resolving a dot shorthand and 1 for not finding a static getter/field in the declaration provided.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I9cc473adf82ca1f74f2370136ac8eec5e97fb23e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/416881
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-25 07:29:02 -07:00
Johnni Winther b9348c7216 [cfe] Handle patches as parts
Change-Id: I50a965b8061572af8a5e408b037648b1f7ff2e0b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413201
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-03-04 01:41:05 -08:00
Johnni Winther 24b14ce246 [cfe] Remove tests using import augment
This is in preparation for a change in the CFE that stops support for 'import augment'.

Change-Id: Ia33b815ec554bae03e3a916ce22830b36e504771
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413221
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-03-04 00:53:03 -08:00
Halil Durmus bb483f34a3 [vm/ffi] Allow configuring the variable dimension of variable-length arrays
TEST=tests/ffi/*

CoreLibraryReviewExempt: VM only
Closes: https://github.com/dart-lang/sdk/issues/52366
Change-Id: I545a323f48d955b591cedf2dae7106d9004242e2
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398621
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-09 22:02:56 +00:00
Johnni Winther e88020be9a [cfe] Add _PreBuilder
This moves the checking of duplicates, member/setter, and static/instance conflicts to a _PreBuilder.

Change-Id: I85f33750c1579676696223d1b19019887ae41e50
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/397163
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-11-27 10:18:50 +00:00
Alexander Markov c409e77d1e Validation of dynamic modules
TEST=pkg/front_end/testcases/general/dynamic_modules


Change-Id: I591d029ed163961f5ece859233874f828d63c857
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388442
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-10-24 16:51:53 +00:00
Johnni Winther 27048206ce [cfe] Rename TypeVariable to TypeParameter
This makes the CFE and kernel terminology consistent.

Change-Id: I6e35d9f4ea58d50eac0ab84763633bf5e445771d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390861
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-10-21 09:35:06 +00:00
Johnni Winther 307e5a62ce [cfe] Include offended version number and package name in too high/low version message
Closes #48819

Change-Id: I8700ed909c916b9c656cc8bc0e34eb1dd6ef0c09
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/390200
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-10-16 06:36:21 +00:00
Johnni Winther 5bcfc0578c [cfe] Cleanup prefix scope
This splits up [computeAmbiguousDeclarationForScope] into
[computeAmbiguousDeclarationForExport], which is moved to [LibraryBuilder], and [computeAmbiguousDeclarationForImport].

Change-Id: I2fad4784904eef6caf731a41300b98c6f172039d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387080
Reviewed-by: Jens Johansen <jensj@google.com>
2024-10-01 09:02:34 +00:00
Moritz 81daf8e563 Use package:record_use
- Rename resource identifiers in the VM to usage recordings.
- Use package:record_use for serialization.
- Rename and use the experimental flag for this feature.
- Recognize tear-offs and top-level methods as well.

Next steps:

- Add constant instance recording.
- Expose API in package:native_assets_cli's link callback.

TEST=pkg/vm/test/transformations/record_use_test.dart

Change-Id: I8af3625165f78925ae943711245af93a239d1012
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/383040
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Moritz Sümmermann <mosum@google.com>
2024-09-12 08:47:53 +00:00
Srujan Gaddam e9a72b80c1 [dart:js_interop] Clear up wording about isA requiring non-generic type argument
Closes https://github.com/dart-lang/sdk/issues/56564

CoreLibraryReviewExempt: Doc-only change.
Change-Id: I0086a0778d53d850c8d746e0474d22382d5e451c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/381942
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2024-09-03 16:03:57 +00:00
pq 6873fcbff0 remove non-existent THIS_ACCESS_FROM_FIELD_INITIALIZER analyzerCode reference
See: https://github.com/dart-lang/sdk/issues/56442

Change-Id: Ifa931c56fe710317d3bbf995f8354ca488711735
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/380884
Auto-Submit: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-08-19 07:13:21 +00:00
Daco Harkes 965234ccbe [vm/ffi] Variable length inline arrays
Adds a new `@Array.variable()` to specify that the last element of
structs is a variable length inline array.

This CL does not add any checks for passing structs with variable
length inline arrays by value or directly calling them with
`AllocatorAlloc.call`. Instead, the implementation defaults to what
C does, allocate as if there are 0 elements in the variable length
inline array.

TEST=tests/ffi/*

CoreLibraryReviewExempt: VM only
Closes: https://github.com/dart-lang/sdk/issues/55964
Change-Id: I524d8a1d710b1a744b392e05fa884908c3ff1f12
Cq-Include-Trybots: dart/try:vm-aot-android-release-arm64c-try,vm-aot-android-release-arm_x64-try,vm-aot-asan-linux-release-x64-try,vm-aot-linux-debug-x64-try,vm-aot-linux-debug-x64c-try,vm-aot-mac-release-arm64-try,vm-aot-mac-release-x64-try,vm-aot-msan-linux-release-x64-try,vm-aot-obfuscate-linux-release-x64-try,vm-aot-optimization-level-linux-release-x64-try,vm-aot-tsan-linux-release-x64-try,vm-aot-ubsan-linux-release-x64-try,vm-aot-win-debug-arm64-try,vm-aot-win-debug-x64-try,vm-aot-win-debug-x64c-try,vm-appjit-linux-debug-x64-try,vm-asan-linux-release-arm64-try,vm-asan-linux-release-x64-try,vm-checked-mac-release-arm64-try,vm-eager-optimization-linux-release-ia32-try,vm-eager-optimization-linux-release-x64-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64c-try,vm-ffi-qemu-linux-release-arm-try,vm-ffi-qemu-linux-release-riscv64-try,vm-fuchsia-release-arm64-try,vm-fuchsia-release-x64-try,vm-linux-debug-ia32-try,vm-linux-debug-x64-try,vm-linux-debug-x64c-try,vm-mac-debug-arm64-try,vm-mac-debug-x64-try,vm-msan-linux-release-arm64-try,vm-msan-linux-release-x64-try,vm-reload-linux-debug-x64-try,vm-reload-rollback-linux-debug-x64-try,vm-tsan-linux-release-arm64-try,vm-tsan-linux-release-x64-try,vm-ubsan-linux-release-arm64-try,vm-ubsan-linux-release-x64-try,vm-win-debug-arm64-try,vm-win-debug-x64-try,vm-win-debug-x64c-try,vm-win-release-ia32-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
2024-08-06 07:50:49 +00:00
Johnni Winther 93f7bbeaad [cfe] Move importScope to SourceCompilationUnit.
Change-Id: Iceb84ba3928bb0d51d2233ef27c3780dedb22bb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/374943
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-07-12 07:39:19 +00:00
Srujan Gaddam 06ec78851b [dart:js_interop] Add static error for converted functions that contain named params
Like type parameters, these parameters can't be passed from JS and
such functions already do not work as intended as there is no way
to pass named args to a JS function. These named parameters were
being silently ignored in dart2wasm when creating the function
trampoline.

Change-Id: Iebb890de05f8b242e0542c1ec8f2c0582c5232df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368062
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2024-06-14 19:42:10 +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
Jackson Gardner 9fa160b706 Revert "[dart2wasm] Check import/export pragmas in user code"
This reverts commit 35bc17a0fa.

Reason for revert: Breaking flutter web engine unit tests: https://github.com/flutter/flutter/issues/149600

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: Iba57910e7492abb7371172ecdb4fc2cc18fed66e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/369500
Reviewed-by: Siva Annamalai <asiva@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Jackson Gardner <jacksongardner@google.com>
2024-06-03 17:28:36 +00:00
Ömer Sinan Ağacan 35bc17a0fa [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>
2024-05-31 09:22:28 +00:00
Ömer Sinan Ağacan dbcf23a5ed [dart2wasm] Disallow dart:ffi in user code
Change-Id: I1d99637e4538a183d8fa567399bfb7c55675e60e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/368568
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Ömer Ağacan <omersa@google.com>
2024-05-31 07:12:21 +00:00
Johnni Winther eb413f21fe [cfe] Remove unused messages
Change-Id: I97542c9558b19d634ac562fdde1cb833f0c22d16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/366666
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2024-05-16 12:37:49 +00:00
Johnni Winther 527176419f [cfe] Report error on expired experiment
An error is now reported if an expired experiment is changed from
its default through the compiler options.

Change-Id: Idc824d7d1f6a1b39443df87ad15b33adf4c04c59
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/365800
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-05-13 08:33:06 +00:00