Commit Graph

389 Commits

Author SHA1 Message Date
Johnni Winther 02c3d9c3f0 [parser] Support declaring parameters
This allows `var int a` in primary constructors when the declaring constructors feature is enabled.

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

Change-Id: I486ad8aa3ddbe09451455b024b3aa9cfbaa9a5e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/456340
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-10-22 01:46:47 -07:00
Konstantin Shcheglov 7ef361bda0 DeCo. Add AST for primary constructors behind feature flag.
This change introduces experimental AST support for the "declaring
constructors" (DeCo) feature and wires the parser to build explicit
nodes for primary constructors. The new behavior is gated by a static
switch:

analyzer/dart/ast/ast.dart: useDeclaringConstructorsAst (experimental)

When the flag is **true** (must be set once before parsing and not
changed thereafter):

* Declarations expose structured bodies:
  - `ClassDeclaration.body` / `MixinDeclaration.body`
  - `EnumDeclaration.body`
  - `ExtensionDeclaration.body`
  - `ExtensionTypeDeclaration.body`
  Legacy bracket/members tokens (`leftBracket`, `members`,
  `rightBracket`) throw `UnsupportedError`.

* The declaration "name" area is modeled as `namePart: ClassNamePart`,
  which is either:
  - `NameWithTypeParameters` (e.g., `A<T>`), or
  - `PrimaryConstructorDeclaration` (e.g., `A<T>.named(...)`).
  Legacy fields (`name`, `typeParameters`) throw `UnsupportedError`.
  For extension types, `representation` also throws under the flag and
  is represented via `PrimaryConstructorDeclaration`.

* Child iteration (`childEntities`), visiting (`visitChildren`), and
  token boundaries (`endToken`) adapt to the new shape.

Parser changes:

* Build `PrimaryConstructorDeclaration` / `PrimaryConstructorName` via a
  new `_PrimaryConstructorBuilder`. For extension types, the existing
  representation syntax is mapped to a primary constructor when the flag
  is enabled.
* Add `NullValue.PrimaryConstructor` to the stack listener to carry the
  parsed primary constructor through the builder pipeline.

Implementation details:

* Introduce small internal *Stub classes (e.g., `ClassBodyImplStub`,
  `EnumBodyImplStub`, `RepresentationDeclarationImplStub`) to satisfy
  constructor requirements for fields that are not surfaced under the
  current mode, avoiding API churn while the feature is gated.
* Update API surface to make `body` and `namePart` available on the
  affected declarations and document which legacy getters throw when the
  flag is enabled.

Rationale:

This lays the AST groundwork for DeCo while preserving backwards
compatibility by default. Consumers can opt in to validate workflows and
migrate incrementally.

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

Change-Id: Ie5300b2958383bf3b2e9d6faf138bb7f74c9d7ed
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455820
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-10-20 18:09:49 -07:00
Johnni Winther 70a453f55f [model] Add ExperimentalFeatures for the parser
This adds an ExperimentalFeatures interface to make the parser able to know which experimental feature is currently supported. This generalizes the existing dependency on patterns and enhanced parts, and facilitates reporting of unsupported features directly within the parser, avoid the need for duplicate handling of this within analyzer+CFE.

Change-Id: If1752745ee4d753e4b463f2017f440223cd98737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455700
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-10-20 05:25:39 -07:00
Johnni Winther e8145a90ed [model] Remove Listener.uri
This wasn't used through the Listener interface.

Change-Id: Ie9fe89c4e07594fa44e38806d226547f6eb6f6a7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455640
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-10-17 04:23:02 -07:00
Johnni Winther 49eb514005 [parser] Support primary constructor on classes, enums and extension types
This adds simple support for primary constructors in class, enum and extension type declarations. Declaring formals are not supported yet.

Change-Id: I2fb2cb3a819e38ec4ffe961da4713a871ac29a0c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/455081
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-10-17 01:52:11 -07:00
Johnni Winther 849a1b5495 [model] Remove support for conditional parts
With https://github.com/dart-lang/language/pull/4520 enhanced parts no longer adds support for conditional parts.

This removes the support in the parser and front-ends, and removes or updates tests.

Change-Id: Id4489c3218c60bbbb8cb94d6e0a83fedc3f94754
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/453800
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-10-08 00:46:12 -07:00
Paul Berry dbdfb1eb60 [front_end] Add withArguments to Template class.
The CFE `Template` class now exposes a `withArguments` method, which
behaves the same as `withArgumetsOld` method, but accepts named
arguments rather than positional arguments.

In follow-up CLs, I will adjust the names of these positional
parameters to be more descriptive, and update call sites to use
`withArguments` rather than `withArgumentsOld`. This should make the
call sites clearer and easier to understand.

Change-Id: I6a6a6964638e0312003aa622c5e0fef782b8d979
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447963
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-09-02 11:47:57 -07:00
Paul Berry 579ad244df [front_end] Rename withArguments to withArgumentsOld.
This is the beginning of a series of CLs intended to change the CFE's
`withArguments` methods (used for diagnostic reporting) so that they
accept named parameters rather than positional parameters. This change
will carry two major benefits:

- It will reduce the risk of mistakes when reporting diagnostics.

- It will make the analyzer and CFE diagnostic reporting mechanisms
  more similar, paving the way for sharing more diagnostic reporting
  code in the future.

As a first step, this CL renames the old `withArguments` methods to
`withArgumentsOld` and updates call sites. In follow-up CLs, I will
introduce new `withArguments` methods that accept named arguments, and
migrate call sites to use them.

Change-Id: I6a6a6964f4130cdb732b14d515e0ad8f2b65dc26
Tested: standard trybots
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/447625
Reviewed-by: Stephen Adams <sra@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-09-02 09:14:21 -07:00
Kallen Tu 9342bac2d9 [parser/analysis_server] Dot shorthands: Code completion for 'const .'
Parser and analysis server changes for adding code completion for `const .^` where `^` is the cursor location.

I modified the parser to handle recovering when we were parsing a dot shorthand constructor invocation that was incomplete.

Added analyzer tests, code completion tests, and frontend parser tests.

Fixes: https://github.com/dart-lang/sdk/issues/59836
Change-Id: Ia200ebd9149658d7563c4942afd749c262c52dc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446987
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-09-02 08:37:48 -07:00
Paul Berry 4e21ee95c0 [_fe_analyzer_shared] Update SDK constraint to ^3.9.0 and reformat files.
Change-Id: I6a6a69642c8c0417d3d8f2680daf68c48694bf03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/446989
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-08-27 06:15:03 -07:00
Jens Johansen 42c5fe7e05 [parser] Fix crash in _attemptPrecedenceLevelRecovery
`_recoverAtPrecedenceLevel` being set to `true` was carried over from
`parsePattern` to `_parsePrecedenceExpressionLoop` which caused it to
crash.

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

Change-Id: I61eec96ebd403bf2167fed11703a2fac03cfc9b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/445260
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-08-14 07:26:41 -07:00
Paul Berry 07c248c6e9 [front end] Use code... instead of message....
This is part of a series of CLs that will standardize CFE error
reporting to always use `codeFoo.withArguments(...)` when reporting
errors that take arguments and `codeFoo` when reporting errors that
don't take arguments, rather than `templateFoo.withArguments(...)`
when reporting errors that take arguments and `messageFoo` when
reporting errors that don't take arguments. This change will have two
advantages:

- It will lend greater consistency to the CFE codebase, by allowing
  the same `code...` objects to be used both to name error codes
  (e.g., in test expectations) and to report errors. This will allow
  everything associated with a certain error code to be found using a
  single invocation of "Find References" in the editor, rather than
  having to search separately for uses of the code and the message or
  template.

- It should hopefully make the experience of writing code that reports
  errors more pleasant, since it will no longer be necessary to look
  up an error to see whether it takes arguments before using it;
  instead, the developer will be able to type the name of the message
  `code...` declaration, and then use autocompletion to see whether
  `.withArguments(...)` is required.

In this CL, references to the `message...` declarations that define
errors are changed to the equivalent `code...` declarations. There is
no functional change, since these declarations denote the same
constant object. In a follow-up CL, the `message...` declarations will
be removed.

Tested: standard trybots
Change-Id: I44d4b3cffb768b908d4341a7851f270db6caa87b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443183
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jackson Gardner <jacksongardner@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2025-08-06 12:16:28 -07:00
Paul Berry 25862913b2 [front end] Use code... instead of template....
This is part of a series of CLs that will standardize CFE error
reporting to always use `codeFoo.withArguments(...)` when reporting
errors that take arguments and `codeFoo` when reporting errors that
don't take arguments, rather than `templateFoo.withArguments(...)`
when reporting errors that take arguments and `messageFoo` when
reporting errors that don't take arguments. This change will have two
advantages:

- It will lend greater consistency to the CFE codebase, by allowing
  the same `code...` objects to be used both to name error codes
  (e.g., in test expectations) and to report errors. This will allow
  everything associated with a certain error code to be found using a
  single invocation of "Find References" in the editor, rather than
  having to search separately for uses of the code and the message or
  template.

- It should hopefully make the experience of writing code that reports
  errors more pleasant, since it will no longer be necessary to look
  up an error to see whether it takes arguments before using it;
  instead, the developer will be able to type the name of the message
  `code...` declaration, and then use autocompletion to see whether
  `.withArguments(...)` is required.

In this CL, the references to the `template...` declarations that
define errors are changed to the equivalent `code...`
declarations. There is no functional change, since these declarations
denote the same constant object. In follow-up CLs, the `template...`
declarations will be removed, and then a similar set of changes will
be made to replace references to `message...` declarations with
references to the corresponding `code...` declaration.

Tested: normal trybots
Change-Id: I178bd2072349088f342bc39cfc789bcb5c7ef19e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442732
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
2025-08-06 07:46:31 -07:00
Jens Johansen c735e0f3e9 [parser] Inline first part of computeTypeParamOrArg
pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
7.9498% +/- 2.2433% (2.03 +/- 0.57) (25.54 -> 27.58)

AOT (tokens per microsecond):
3.9940% +/- 0.8571% (1.39 +/- 0.30) (34.84 -> 36.23)

Benchmarker (AOT):
```
msec task-clock:u: -2.4837% +/- 1.2807% (-58.16 +/- 29.99) (2341.68 -> 2283.52)
page-faults:u: 0.0088% +/- 0.0076% (0.90 +/- 0.78) (10258.82 -> 10259.72)
cycles:u: -2.5716% +/- 1.2746% (-261496302.16 +/- 129603257.37) (10168495138.96 -> 9906998836.80)
instructions:u: -5.9203% +/- 0.0000% (-1176053117.46 +/- 458.74) (19864798003.98 -> 18688744886.52)
seconds time elapsed: -2.4846% +/- 1.2792% (-0.06 +/- 0.03) (2.34 -> 2.28)
seconds user: -2.4639% +/- 1.3110% (-0.06 +/- 0.03) (2.32 -> 2.26)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
6.1828% +/- 0.7674% (1.37 +/- 0.17) (22.08 -> 23.44)

AOT (tokens per microsecond):
4.9375% +/- 0.7729% (1.46 +/- 0.23) (29.62 -> 31.08)

Benchmarker (AOT):
```
msec task-clock:u: -4.9727% +/- 0.7290% (-103.08 +/- 15.11) (2072.86 -> 1969.78)
page-faults:u: 0.0090% +/- 0.0089% (0.90 +/- 0.89) (9945.40 -> 9946.30)
cycles:u: -5.0714% +/- 0.7198% (-456150857.90 +/- 64747402.08) (8994574286.86 -> 8538423428.96)
instructions:u: -7.2480% +/- 0.0000% (-1295719231.76 +/- 509.18) (17876882695.30 -> 16581163463.54)
seconds time elapsed: -4.9640% +/- 0.7298% (-0.10 +/- 0.02) (2.07 -> 1.97)
seconds user: -5.1717% +/- 0.7510% (-0.11 +/- 0.02) (2.05 -> 1.95)
```

Change-Id: I0ecf4db48b0bc5dc5f45d51260f612c9872295fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443781
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-08-05 04:48:30 -07:00
Jens Johansen e3d4534006 [parser] Redo loops in _parsePrecedenceExpressionLoop
pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
6.3638% +/- 1.0454% (1.58 +/- 0.26) (24.83 -> 26.41)

AOT (tokens per microsecond):
7.2915% +/- 0.9305% (2.36 +/- 0.30) (32.32 -> 34.68)

Benchmarker (AOT):
```
msec task-clock:u: -6.8409% +/- 0.8755% (-171.31 +/- 21.92) (2504.18 -> 2332.87)
cycles:u: -6.9075% +/- 0.8852% (-749508513.10 +/- 96049038.00) (10850656620.68 -> 10101148107.58)
instructions:u: -8.4679% +/- 0.0000% (-1836882019.72 +/- 365.67) (21692257748.84 -> 19855375729.12)
branch-misses:u: -8.1101% +/- 2.9770% (-2397153.78 +/- 879942.27) (29557566.12 -> 27160412.34)
seconds time elapsed: -6.8416% +/- 0.8753% (-0.17 +/- 0.02) (2.51 -> 2.33)
seconds user: -6.8903% +/- 0.8879% (-0.17 +/- 0.02) (2.48 -> 2.31)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
9.6105% +/- 0.7962% (1.93 +/- 0.16) (20.03 -> 21.96)

AOT (tokens per microsecond):
11.6797% +/- 1.0269% (3.09 +/- 0.27) (26.47 -> 29.57)

Benchmarker (AOT):
```
msec task-clock:u: -9.6901% +/- 0.8600% (-222.58 +/- 19.75) (2297.04 -> 2074.46)

cycles:u: -9.7982% +/- 0.8724% (-974597873.18 +/- 86776670.77) (9946712953.30 -> 8972115080.12)
instructions:u: -15.1329% +/- 0.0000% (-3186976224.52 +/- 513.54) (21059918941.74 -> 17872942717.22)
seconds time elapsed: -9.6858% +/- 0.8600% (-0.22 +/- 0.02) (2.30 -> 2.08)
seconds user: -9.7480% +/- 0.8797% (-0.22 +/- 0.02) (2.28 -> 2.05)
```
Change-Id: Ie143d11acd36e6a7ebff79862481d7c888300844
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443520
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-08-04 23:41:30 -07:00
Lasse R.H. Nielsen 56b68442fe Parse ?. as ?+. in element.
Bug: https://dartbug.com//language/4477

Change-Id: If68b21a2b22ed65dde09c03dab8a3f4721a2fa34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442480
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-08-04 03:21:33 -07:00
Jens Johansen bd0fa88e0b [parser] Inline first part of _tryRewriteNewToIdentifier
pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
1.3425% +/- 1.0526% (0.33 +/- 0.26) (24.64 -> 24.98)

AOT (tokens per microsecond):
1.1587% +/- 0.7860% (0.38 +/- 0.26) (32.45 -> 32.83)

Benchmarker (AOT):
```
instructions:u: -1.9853% +/- 0.0000% (-439384607.18 +/- 518.28) (22131742462.46 -> 21692357855.28)
```

pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
1.4245% +/- 0.7653% (0.28 +/- 0.15) (19.90 -> 20.18)

AOT (tokens per microsecond):
1.7105% +/- 0.8890% (0.45 +/- 0.23) (26.25 -> 26.70)

Benchmarker (AOT):
```
msec task-clock:u: -1.3071% +/- 0.8717% (-30.64 +/- 20.44) (2344.53 -> 2313.89)

page-faults:u: -0.0097% +/- 0.0084% (-0.96 +/- 0.84) (9945.42 -> 9944.46)
cycles:u: -1.4071% +/- 0.8701% (-143026423.34 +/- 88437058.62) (10164329405.06 -> 10021302981.72)
instructions:u: -2.2650% +/- 0.0000% (-488077498.12 +/- 960.50) (21548947043.38 -> 21060869545.26)
branch-misses:u: -3.7824% +/- 3.3800% (-1316798.12 +/- 1176704.41) (34813893.88 -> 33497095.76)
seconds time elapsed: -1.3039% +/- 0.8711% (-0.03 +/- 0.02) (2.35 -> 2.32)
seconds user: -1.3918% +/- 0.8962% (-0.03 +/- 0.02) (2.32 -> 2.29)
```
Change-Id: Ide847121b70db8564f1ea7f9d77ea5d63da1d6ac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443081
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-31 05:44:50 -07:00
Jens Johansen d337376f5c [parser] Cheaper recovery for List<Foo>[ and Map<Foo, Bar>{}
Recovery for erroneous literals like `Map<int, int>{}` was added in
https://dart-review.googlesource.com/c/sdk/+/190022. This CL makes it
cheaper.

pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
No change.

AOT (tokens per microsecond):
7.9552% +/- 2.1091% (2.41 +/- 0.64) (30.27 -> 32.67)

Benchmarker (AOT):
```
msec task-clock:u: -2.1591% +/- 0.8194% (-55.46 +/- 21.05) (2568.82 -> 2513.36)
page-faults:u: 0.2247% +/- 0.0145% (23.00 +/- 1.49) (10235.92 -> 10258.92)
cycles:u: -2.2243% +/- 0.8087% (-248083632.76 +/- 90197190.45) (11153502206.48 -> 10905418573.72)
instructions:u: -3.6023% +/- 0.0000% (-827054283.92 +/- 721.20) (22958796659.48 -> 22131742375.56)
seconds time elapsed: -2.1582% +/- 0.8241% (-0.06 +/- 0.02) (2.57 -> 2.51)
seconds user: -2.2825% +/- 0.8882% (-0.06 +/- 0.02) (2.55 -> 2.49)
```

pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
4.3711% +/- 1.3011% (0.84 +/- 0.25) (19.11 -> 19.94)

AOT (tokens per microsecond):
5.3025% +/- 1.0032% (1.32 +/- 0.25) (24.95 -> 26.27)

Benchmarker (AOT):
```
msec task-clock:u: -4.2295% +/- 1.0942% (-104.20 +/- 26.96) (2463.65 -> 2359.45)
page-faults:u: 0.0773% +/- 0.0141% (7.68 +/- 1.40) (9937.76 -> 9945.44)
cycles:u: -4.3497% +/- 1.0959% (-465492322.32 +/- 117280203.19) (10701783151.44 -> 10236290829.12)
instructions:u: -5.0470% +/- 0.0000% (-1145391707.84 +/- 802.85) (22694337726.36 -> 21548946018.52)
seconds time elapsed: -4.2224% +/- 1.0991% (-0.10 +/- 0.03) (2.47 -> 2.36)
seconds user: -4.2597% +/- 1.1024% (-0.10 +/- 0.03) (2.44 -> 2.34)
```
Change-Id: I77b865c455d80557646b77921f0b808383c67bdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/443060
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-31 04:22:31 -07:00
Johnni Winther 9404899248 [parser] Split handleEndingBinaryExpression into handleDotAccess and handleCascadeAccess
This splits handleEndingBinaryExpression into two new listeners handleDotAccess for `.` and `?.` access and handleCascadeAccess for `..` and `?..`, both with an explicit `isNullAware` flag.

This is a step towards handling `a.b` different from `a + b` in the parser such that listeners don't have to create a value for `b` the works in both use cases; in the first is just a named operation performed on the receiver, whereas in the second case it is a full expression in its own right.

Change-Id: I04ec80401f8f2dbb8dffa86543c434e530b18cf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442821
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2025-07-31 02:02:28 -07:00
Jens Johansen 04096b9891 [parser] Shortcut more common cases in parseArgumentsRest
A few more common cases: "<identifier> <period> <identifier> <comma>",
"<identifier> <period> <identifier> <end parens>", "<string> <comma">
and "<string> <end parens>".

pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
4.8482% +/- 1.4622% (1.11 +/- 0.34) (22.92 -> 24.03)

AOT (tokens per microsecond):
4.5974% +/- 1.6421% (1.40 +/- 0.50) (30.53 -> 31.94)

Benchmarker (AOT):
```
msec task-clock:u: -4.7108% +/- 2.0520% (-124.92 +/- 54.41) (2651.72 -> 2526.80)
cycles:u: -4.7512% +/- 2.0346% (-546787446.10 +/- 234152251.09) (11508497283.00 -> 10961709836.90)
instructions:u: -4.5849% +/- 0.0000% (-1115885935.90 +/- 1109.34) (24338242436.20 -> 23222356500.30)
seconds time elapsed: -4.7090% +/- 2.0523% (-0.12 +/- 0.05) (2.65 -> 2.53)
seconds user: -4.8217% +/- 2.0991% (-0.13 +/- 0.06) (2.63 -> 2.51)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
11.5950% +/- 3.4217% (1.96 +/- 0.58) (16.91 -> 18.87)

AOT (tokens per microsecond):
11.7128% +/- 1.4863% (2.61 +/- 0.33) (22.32 -> 24.94)

Benchmarker (AOT):
```
msec task-clock:u: -8.9523% +/- 0.8309% (-244.45 +/- 22.69) (2730.57 -> 2486.12)

page-faults:u: 0.0503% +/- 0.0216% (5.00 +/- 2.14) (9933.10 -> 9938.10)
cycles:u: -9.0605% +/- 0.8306% (-1075717286.20 +/- 98615789.63) (11872662784.50 -> 10796945498.30)
instructions:u: -13.7568% +/- 0.0000% (-3608232664.50 +/- 836.10) (26228691068.30 -> 22620458403.80)
branch-misses:u: 6.9875% +/- 4.6549% (2539140.50 +/- 1691509.92) (36338407.60 -> 38877548.10)
seconds time elapsed: -8.9450% +/- 0.8300% (-0.24 +/- 0.02) (2.73 -> 2.49)
seconds user: -8.9919% +/- 0.8899% (-0.24 +/- 0.02) (2.71 -> 2.47)
```
Change-Id: I207a35d8107ba1604646e387e590aa19a4ccd996
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439900
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-31 00:41:31 -07:00
Jens Johansen 59f19d8771 [parser] Shortcut common case in parseArgumentsRest
Observation: Often when about to call parseExpression in
parseArgumentsRest we see either "<identifier> <comma>" (say, we're
passing a variable) or "<identifier> <end parens>" (same case, but last
argument).

This CL allows us to shortcut such cases avoiding a lot of calls where
we check if it's other cases which it isn't.

pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
5.5605% +/- 4.0086% (1.16 +/- 0.84) (20.94 -> 22.10)

AOT (tokens per microsecond):
7.1788% +/- 2.5682% (2.04 +/- 0.73) (28.44 -> 30.48)

Benchmarker (AOT):
```
msec task-clock:u: -4.4173% +/- 1.7793% (-124.29 +/- 50.07) (2813.81 -> 2689.52)
page-faults:u: 0.1064% +/- 0.0131% (10.90 +/- 1.35) (10246.00 -> 10256.90)
cycles:u: -4.4718% +/- 1.7882% (-546472914.30 +/- 218528412.28) (12220314431.60 -> 11673841517.30)
instructions:u: -10.0011% +/- 0.0000% (-2704578213.40 +/- 1611.58) (27042820700.90 -> 24338242487.50)
seconds time elapsed: -4.4160% +/- 1.7779% (-0.12 +/- 0.05) (2.82 -> 2.69)
seconds user: -4.6324% +/- 1.8285% (-0.13 +/- 0.05) (2.80 -> 2.67)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
10.1981% +/- 1.2476% (1.58 +/- 0.19) (15.46 -> 17.04)

AOT (tokens per microsecond):
8.7843% +/- 1.5781% (1.79 +/- 0.32) (20.42 -> 22.22)

Benchmarker (AOT):
```
msec task-clock:u: -5.9322% +/- 2.7532% (-181.01 +/- 84.01) (3051.38 -> 2870.37)

page-faults:u: 0.0352% +/- 0.0261% (3.50 +/- 2.59) (9930.90 -> 9934.40)
cycles:u: -6.0726% +/- 2.7273% (-805818237.40 +/- 361907438.70) (13269703092.60 -> 12463884855.20)
instructions:u: -11.9540% +/- 0.0000% (-3561054138.90 +/- 1016.14) (29789745342.80 -> 26228691203.90)
seconds time elapsed: -5.9310% +/- 2.7520% (-0.18 +/- 0.08) (3.05 -> 2.87)
seconds user: -6.1531% +/- 2.7477% (-0.19 +/- 0.08) (3.03 -> 2.85)
```
Change-Id: Ia4fbdcbd438a38a0c07b3f4423812ef3507b626c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439880
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-31 00:41:03 -07:00
Paul Berry 7ac80be476 [front end] Remove type argument from class Code.
This type argument was never used. Removing it should make it easier
to make changes to the front end error message logic (and associated
code generator), which I intend to do as part of a long term plan to
make the analyzer and front end error reporting systems more
consistent, and eventually merge them.

Change-Id: I994cd2a74c5fd77df192f6a1f2dde46ba8a31883
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442723
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-07-30 12:38:27 -07:00
Jens Johansen 86b65842ed [parser] Manually inline 'isNextIdentifier'
pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
2.1064% +/- 1.6771% (0.44 +/- 0.35) (20.97 -> 21.42)

AOT (tokens per microsecond):
No change.

Benchmarker (AOT):
```
msec task-clock:u: -1.2559% +/- 0.6202% (-35.75 +/- 17.65) (2846.58 -> 2810.83)
cycles:u: -1.3051% +/- 0.6113% (-161347113.30 +/- 75579075.11) (12362747585.00 -> 12201400471.70)
instructions:u: -0.6245% +/- 0.0000% (-169931728.50 +/- 1390.09) (27212753414.40 -> 27042821685.90)
seconds time elapsed: -1.2465% +/- 0.6111% (-0.04 +/- 0.02) (2.85 -> 2.81)
seconds user: -1.3083% +/- 0.7709% (-0.04 +/- 0.02) (2.83 -> 2.79)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
No change.

AOT (tokens per microsecond):
No change.

Benchmarker (AOT):
```
instructions:u: -0.9284% +/- 0.0000% (-279155451.00 +/- 502.76) (30068900827.90 -> 29789745376.90)
```

Change-Id: I70eaae39d156f77e5e451a8592f6f3dab2da3d67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439780
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-30 07:13:16 -07:00
Jens Johansen 752b760308 [parser] notEofOrValue -> notEofOrType - skip string comparison
A small one.

pkg/analyzer/lib/src/dart/ast/ast.dart:

JIT (tokens per microsecond):
1.7597% +/- 1.4621% (0.37 +/- 0.30) (20.79 -> 21.15)

AOT (tokens per microsecond):
2.2547% +/- 1.6761% (0.62 +/- 0.46) (27.67 -> 28.30)

Benchmarker (AOT):
```
msec task-clock:u: -2.4779% +/- 1.3546% (-73.29 +/- 40.07) (2957.87 -> 2884.58)
cycles:u: -2.6238% +/- 1.3918% (-337224094.10 +/- 178886541.74) (12852601263.80 -> 12515377169.70)
instructions:u: -0.9484% +/- 0.0000% (-260552753.00 +/- 375.88) (27473305680.40 -> 27212752927.40)
branch-misses:u: -8.7134% +/- 6.9328% (-3191115.20 +/- 2538992.37) (36623085.10 -> 33431969.90)
seconds time elapsed: -2.4691% +/- 1.3512% (-0.07 +/- 0.04) (2.96 -> 2.89)
seconds user: -2.4294% +/- 1.3675% (-0.07 +/- 0.04) (2.93 -> 2.86)
```


pkg/front_end/lib/src/type_inference/inference_visitor.dart:

JIT (tokens per microsecond):
No change.

AOT (tokens per microsecond):
No change.

Benchmarker (AOT):
```
msec task-clock:u: -4.3099% +/- 1.9546% (-136.28 +/- 61.81) (3162.10 -> 3025.81)
cycles:u: -4.3066% +/- 1.9530% (-592061704.80 +/- 268488936.68) (13747787475.20 -> 13155725770.40)
instructions:u: -0.5194% +/- 0.0000% (-156988901.90 +/- 1876.14) (30225890142.20 -> 30068901240.30)
branch-misses:u: -14.2999% +/- 7.5350% (-6167339.80 +/- 3249736.99) (43128654.50 -> 36961314.70)
seconds time elapsed: -4.3098% +/- 1.9527% (-0.14 +/- 0.06) (3.16 -> 3.03)
seconds user: -4.3252% +/- 1.9575% (-0.14 +/- 0.06) (3.14 -> 3.01)
```

Change-Id: Ib70398e337c482f7427debb6875e2c17ccc6bd0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439740
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-07-30 07:06:17 -07:00
Jens Johansen 06402ab1ca [parser] Optimize mayFollowTypeArgs
Doing benchmarks before and after I get the below.
Notice that this is on tokens/ms, i.e. higher is better.

JIT:

pkg/analyzer/lib/src/dart/ast/ast.dart:

```
Difference at 95.0% confidence
        1.27922 +/- 0.393002
        6.47159% +/- 1.9882%
        (Student's t, pooled s = 0.418268)
```

pkg/front_end/lib/src/type_inference/inference_visitor.dart:

```
Difference at 95.0% confidence
        0.968609 +/- 0.287367
        6.8824% +/- 2.04187%
        (Student's t, pooled s = 0.305841)
```

In both cases it processes a little over 6% more tokens per ms.

AOT:

pkg/analyzer/lib/src/dart/ast/ast.dart:

```
Difference at 95.0% confidence
        2.39988 +/- 0.429312
        9.50898% +/- 1.70105%
        (Student's t, pooled s = 0.456911)
```

pkg/front_end/lib/src/type_inference/inference_visitor.dart:

```
Difference at 95.0% confidence
        2.28604 +/- 0.279366
        12.9521% +/- 1.58282%
        (Student's t, pooled s = 0.297326)
```

It processes between 9-13% more tokens per ms.


Additionally, for AOT, I ran it through the benchmarker and got this:

pkg/analyzer/lib/src/dart/ast/ast.dart:

```
msec task-clock:u: -8.5488% +/- 2.1840% (-275.52 +/- 70.39) (3222.95 -> 2947.42)
cycles:u: -8.6402% +/- 2.1619% (-1210657004.60 +/- 302921394.06) (14011942063.40 -> 12801285058.80)
instructions:u: -9.0870% +/- 0.0000% (-2746030853.20 +/- 876.33) (30219334757.30 -> 27473303904.10)
branch-misses:u: -13.3846% +/- 10.1850% (-5542357.40 +/- 4217459.09) (41408381.20 -> 35866023.80)
seconds time elapsed: -8.5442% +/- 2.1816% (-0.28 +/- 0.07) (3.22 -> 2.95)
seconds user: -8.5614% +/- 2.2098% (-0.27 +/- 0.07) (3.20 -> 2.93)
```

pkg/front_end/lib/src/type_inference/inference_visitor.dart

```
msec task-clock:u: -11.6033% +/- 0.9079% (-402.51 +/- 31.50) (3468.96 -> 3066.45)
cycles:u: -11.6826% +/- 0.9053% (-1765194611.60 +/- 136793475.00) (15109578869.80 -> 13344384258.20)
instructions:u: -11.4435% +/- 0.0000% (-3905886611.70 +/- 1150.33) (34131775222.10 -> 30225888610.40)
branch-misses:u: -17.5244% +/- 4.6453% (-8196278.70 +/- 2172645.25) (46770630.60 -> 38574351.90)
seconds time elapsed: -11.6004% +/- 0.9056% (-0.40 +/- 0.03) (3.47 -> 3.07)
seconds user: -11.6215% +/- 0.9879% (-0.40 +/- 0.03) (3.45 -> 3.05)
```

I.e. in both cases it's 8-11% less work (instructions, time etc).

Compiling the CFE with the CFE before and after (AOT) I get this change:

```
msec task-clock:u: -0.4356% +/- 0.3110% (-23.07 +/- 16.47) (5295.49 -> 5272.42)
page-faults:u: 0.1135% +/- 0.0534% (123.64 +/- 58.22) (108956.82 -> 109080.46)
cycles:u: -0.5004% +/- 0.3175% (-109702416.52 +/- 69596415.67) (21921571730.18 -> 21811869313.66)
instructions:u: -0.3994% +/- 0.0005% (-104979706.80 +/- 138268.02) (26284569470.80 -> 26179589764.00)
branch-misses:u: -1.6117% +/- 1.4644% (-1285239.90 +/- 1167813.84) (79746730.52 -> 78461490.62)
seconds time elapsed: -0.4291% +/- 0.3090% (-0.02 +/- 0.02) (5.30 -> 5.28)
seconds user: -0.3992% +/- 0.3801% (-0.02 +/- 0.02) (5.04 -> 5.02)
```

So this improvement to the parser reduces the runtime of compiling by ~0.4%.

Change-Id: Ia89d02e8cce2655fb23ffe18ecbab63521ce75e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439721
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2025-07-30 07:05:12 -07:00
Johnni Winther 9c5eea2b1a [parser] Push handleEndingBinaryExpression implementation into subclasses
This moves implementation handling calls to handleEndingBinaryExpression into its own method in the subclasses. This splits the `.`, `.?`, `..` and `?..` from the real binary expressions.

This is a step towards handling `a.b` different from `a + b` in the parser such that listeners don't have to create a value for `b` the works in both use cases; in the first is just a named operation performed on the receiver, whereas in the second case it is a full expression in its own right.

Change-Id: I5291439f333971b7ff482325a15502e4d8a66b71
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/442820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-07-30 06:12:41 -07:00
Kallen Tu 676a40ec54 [parser] Dot shorthands: Recover as a DotShorthandPropertyAccess rather than a PrefixedIdentifier.
This change mainly has side effects for code completion, making sure we're suggesting the right members. When the user writes something like `E e = .^` where `^` is the cursor, they're most likely intending to write a dot shorthand.

So this parser recovery change ensures that we recover as a dot shorthand node and not as a prefixed identifier (missing it's target) in the analyzer. We don't need special casing in the code completion pass to handle dot shorthands in the prefixed identifier visitor now.

The CFE should have no notable changes, but I added a few tests since it uncovered some crashing behavior. The duplicate errors have always been the case even prior to this change.

Bug: https://github.com/dart-lang/sdk/issues/59836
Change-Id: I6c4a9f2c8cc376e4dedd715af76967da471aa681
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/439140
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2025-07-21 11:45:32 -07:00
Jens Johansen b246cad216 [parser] Change NullValue usage
This gets rid of (what is described in commented code as)
InstantiatedTypeWithArgumentsTest, Subtype1TestCacheLookup, BoolTest.

Running this through the benchmarker like this:

```
out/ReleaseX64/dart-sdk/bin/dart pkg/front_end/tool/benchmarker.dart \
  --snapshot=pkg/analysis_server/bin/server.aot.1 \
  --snapshot=pkg/analysis_server/bin/server.aot.2 \
  --arguments="--disable-file-byte-store" \
  --arguments="--train-using" \
  --arguments="pkg/front_end/lib/"
```

(there `server.aot.1` is without this CL and `server.aot.2` is with)
I get:

```
msec task-clock:u: -0.9614% +/- 0.3557% (-78.23 +/- 28.95) (8136.80 -> 8058.57)
cycles:u: -1.0257% +/- 0.3626% (-348283560.66 +/- 123129577.69) (33955507948.94 -> 33607224388.28)
instructions:u: -1.0595% +/- 0.0662% (-479117043.74 +/- 29935955.93) (45220681554.68 -> 44741564510.94)
seconds time elapsed: -0.9548% +/- 0.3540% (-0.08 +/- 0.03) (8.15 -> 8.07)
seconds user: -1.0649% +/- 0.4031% (-0.08 +/- 0.03) (7.80 -> 7.72)
Scavenge(   new space) goes from 130 to 129
Notice combined GC time goes from 2613 ms to 2608 ms (notice only 1 run each).
```

`StackImpl.pop` as reported by `perf report --no-children` goes from
0.81% to 0.34% (and I'm unsure why the apparent change seen as a whole
is quite a bit bigger).

Change-Id: Ife36da11215e0c8aa706d945f0ee5018ad03ab91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/432340
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2025-06-03 04:58:51 -07:00
Paul Berry 0fcd1a6fa1 Bump _fe_analyzer_shared to SDK 3.7 and reformat
Change-Id: I70157caf90c0955c2eb8426f5721ba4ed527eb76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/427900
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Auto-Submit: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2025-05-10 15:32:50 -07:00
Kallen Tu 29bc21c6d7 [analyzer] Dot shorthands: Add DotShorthandMixin to PostfixExpression to handle null-assert expressions.
The parser now handles the `!` operator which wouldn't be captured originally because we are parsing the shorthand with SELECTOR_PRECEDENCE.

Added a language test since no tests currently cover the usage of `!` and a few unit tests.

Bug: https://github.com/dart-lang/sdk/issues/59835
Change-Id: I66bdcc9a083c98d91b16d3ce8c952b8d4010ecd9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/425155
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-05-09 09:57:28 -07:00
Kallen Tu 4ddb83ea9b [parser] Dot shorthands: Remove synthetic token in parser.
Context:
A while back, I inserted a synthetic token in the parser to allow us to parse without crashing the analyzer while I worked on the CFE. Now that both implementations are up and working, we can remove this synthetic token and allow the parser to parse as if we had enabled dot shorthands by default, and produce an error if the experiment isn't enabled.

This change allows a bunch of different language tests to start passing since they were blocked on the weird synthetic token messing up the parsing stream.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I792e3b917a76241b04ee708de06f670bbde64036
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/423563
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-04-24 13:38:48 -07:00
Johnni Winther dced5e0482 [cfe] Add LocalTypeParameterScope
This cleans up the LocalScope interface and the handling of named function expressions.

Change-Id: Id0432910a9e65d8ae966dfab67c66248639d241a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/419842
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-04-03 03:43:30 -07:00
Kallen Tu 9b116d047b [cfe] Dot shorthands - Const constructors
Parse and build dot shorthand invocations that are constant.
Added a new listener to handle and store the const-ness. It didn't feel right re-using any of the other `beginConstPattern` methods.

Added an error message if invoking a non-const constructor where we expected a const constructor.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I8551e3b8f71e89a69d090510bb64694d5e09247d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/414660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-19 08:52:23 -07:00
Kallen Tu e52b141660 [cfe] Fix bug with expression parsing with dot shorthands.
This CL is a bug fix where we weren't parsing the rest of the expression after the dot shorthand.
This caused errors in parsing dot shorthands expressions such as `.red..toString();` or `fn(.parse('true') || false)`.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I745f45e04af53eac0cfcebe7ab977b918da10fbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/413920
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-03-06 13:17:32 -08:00
Kallen Tu c9aa87bf26 [parser] Avoid an extra error in CFE for dot shorthands.
The parser was still WIP and was emitting an extra error, so this CL removes that error so tests can start passing and so I can properly test the new implementation e2e.

It still needs some fixes after the analyzer implementation is complete. The current extra synthetic tokens added in the parser are temporary to prevent crashes on the analyzer side when the experiment flag is turned off. But it works fine for now, and I'll clean it up in a CL when the feature is complete.

Bug: https://github.com/dart-lang/sdk/issues/59758
Change-Id: I83d8c840f66bedff4aa27a737a3f57e77d3973b8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/412344
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2025-02-27 09:53:10 -08:00
Kallen Tu ef2dcd5f48 [parser] Initial parsing of dot shorthands.
Doing some initial work for parsing dot shorthands.

The listeners in the CFE and analyzer will report an extra error if the experiment is not turned on. The compilation should still fail and produce errors, but it won't crash.

If you turn on the experiment, the parsing will crash, but I'd like to get this in so I can modularly work on the CFE and analyzer separately.

Bug: https://github.com/dart-lang/sdk/issues/59758, https://github.com/dart-lang/sdk/issues/59835
Change-Id: I262b0bd5cffc8e5e04ac79c76454b6e355779ade
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409540
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-02-18 12:45:53 -08:00
Johnni Winther d3f28d77d1 [cfe] Support parts with imports/parts
This is a part of the enhanced-parts feature needed for further progress on the Builder model migration where patch libraries should be handled as patch parts.

Change-Id: I253b471df56ce383eaf5de18b3287ec3cc161005
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/409700
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2025-02-17 03:40:08 -08:00
Johnni Winther f797e5f138 [cfe] Remove MixinApplicationBuilder
Change-Id: I2780f63c1d63655cc23d44426f29d5d9a040c5f6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/406841
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2025-01-30 05:48:42 -08:00
Jens Johansen c075d939e0 [parser/scanner] Remove ScannerConfig enableNonNullable
Change-Id: If6bfbb65a02ac1a4f5708ab9e8c4d66c19ecff86
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403984
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-13 00:32:35 -08:00
Jens Johansen 5dfce919cd [parser/scanner] Remove ScannerConfig enableExtensionMethods
Extension methods can no longer be disabled. This CL removes the option
from the scanner config and the parser related specific recovery.
It also removes any specific (triggered) test of the functionality.
A follow-up CL will do the same for NNBD.

Change-Id: Ia385008e5ed1333fb37697b8fe424b8759bce198
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/403581
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2025-01-13 00:32:25 -08:00
Jens Johansen e30f60791a [parser] Don't use the next token as the end on handleSend
Change-Id: Ic4bacffab3fdd9d23bea9b1ecd0f2cfdecb82e2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399060
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-12-05 15:10:34 +00:00
Jens Johansen 67ead166f5 [parser/CFE] Better recovery of partial missing type arguments on type; fix CFE crash
Change-Id: Ifd43ca5b5167e8bacf36e7b89ed8ab57362635b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/399040
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2024-12-05 15:04:00 +00:00
Jens Johansen bce3dd4fe7 [CFE/shared] Make formatting more consistent by specifying DartFormatter.latestShortStyleLanguageVersion
Autogenerated files was formatted with the new style, so if one for
instance formatted the file via the IDE or by saying
`out/ReleaseX64/dart-sdk/bin/dart format pkg/front_end/lib/` we'd get
*a lot* of changes which isn't great.
This CL sets the formatter version for the auto-generated files,
hopefully avoiding such things.

Change-Id: I4f92aafde7c77e7c78179f78bf821979a25ec12c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/398884
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-12-05 08:50:30 +00:00
Johnni Winther eb8156415c [cfe] Remove use of 'fasta' in (file)names
Change-Id: Iac3850696fb5e48dff847d17f7110644e8b8bd03
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395920
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-11-20 14:22:56 +00:00
Johnni Winther 72534f18fa [cfe] Remove library fasta.* names
Change-Id: I0a678e971395f70d09a3faf004e6476a9b5a48cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395000
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2024-11-14 07:32:21 +00:00
Jens Johansen 4b7c6b1fa6 [parser] Remove (extension) Token.isA2
With 0ca1ff2281 fixing the reason why we
had `isA2` we can get rid of it. One 100-run-each-benchmark of compiling
a fixed version of the CFE with the current version of the CFE I get

```
msec task-clock:u: -0.3133% +/- 0.2298% (-13.22 +/- 9.70)
cycles:u: -0.4109% +/- 0.2303% (-71702583.62 +/- 40176749.86)
instructions:u: -0.0150% +/- 0.0002% (-3206465.75 +/- 50567.00)
branch-misses:u: -0.9597% +/- 0.8046% (-615355.48 +/- 515877.98)
seconds time elapsed: -0.3138% +/- 0.2297% (-0.01 +/- 0.01)
seconds user: -0.2991% +/- 0.2978% (-0.01 +/- 0.01)
```

(the only real thing to look at here is likely the `instructions:u`
going down by ~3.2 mio.)

For anyone interested:
Manualy testing what 0ca1ff2281 did vs
the commit before (by running it 5 times each by hand through perf stat)
I get

instructions:u: -0.0831338% +/- 0.00115149% (-1.78503e+07 +/- 247246)
(i.e. almost 18 mio less instructions).
Change-Id: I01600c33364933da262b3354298255e8b2df8afb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394101
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-11-13 15:10:51 +00:00
Jens Johansen 0b07f2ebae [parser] Better recovery on variable declaration with missing name before type parameter
Change-Id: Ie3e2995748c6f36c2cd98235658cbadfc53157a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/394303
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2024-11-13 08:41:41 +00:00
Jens Johansen a0c4efddb8 [parser] Don't try to parse a function literal when in a continuation
Fixes https://github.com/dart-lang/sdk/issues/49477

Change-Id: Ie290a1af08ecc5c2cd270af21adeb43943ec289b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/393340
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-11-12 08:16:42 +00:00
Jens Johansen 0512c58348 [parser] Use allowCascades when calling parseThrowExpression in _parsePrecedenceExpressionLoop instead of just false
For now, see what happens.

Bug: https://github.com/dart-lang/sdk/issues/54284
Change-Id: I8e9f081ae3aa5caff7e155ef628e90547cc8afe6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392561
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-11-11 09:08:40 +00:00
Jens Johansen 817882c36b [parser] Recover missing identifier in new style typedef
Before, when parsing a new style typedef without an identifier (e.g.
`typedef = whatnot`) it concluded that the token after the equal-sign
wasn't an equal sign an that it thus had to be an old style typedef,
followed by recovery there.

This CL makes the recovery insert an identifier after `typedef` (what
the recovery of the old style actually did too), and then parse it as a
new style typedef.

This causes the previous many errors to just be `Expected an identifier,
but got '='.`

It is furthermore verified that the parsing of such a case is ~the same
as when having an indentifier.

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

Change-Id: I5cde1f29839555b1d6027a7d040dc6f60ac614a5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/392560
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2024-11-04 11:18:38 +00:00