Commit Graph

161 Commits

Author SHA1 Message Date
Jens Johansen cec94a1446 [parser] Empty record types, record types with 1 element
This should bring parsing of record types up-to-date with v1.6 of
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Also fixes https://github.com/dart-lang/sdk/issues/49826

Change-Id: I3737a72ddee49a957bd55f86cc200fb77f23e2a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256660
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-08-30 11:04:10 +00:00
Jens Johansen a4352d09e1 [parser] Record literals can be const and one-element only
This should bring parsing of record literals up-to-date with v1.6 of
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Change-Id: If39bb1834137da55ef8bd1923106bbc614ea319b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256461
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-08-30 10:54:08 +00:00
Jens Johansen 4970534cab [parser] Allow ? to be parsed a part of the type after is/as right before end bracket
Before this was ok:

```
  var x = [a as int?, a];
```

but this was not:

```
  var x = [a, a as int?];
```

Nor was this:

```
list[i as int?];
```

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

Change-Id: I8a169e15b189965ad19ad489e8a0a6f02c09b34b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256300
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-08-25 13:47:22 +00:00
Jens Johansen 7aeea765d8 [parser] Parse record type return types for functions taking type parameters
Fixes https://github.com/dart-lang/sdk/issues/49794

Change-Id: Ie80497bcfcda42cfb082240346ed547586742598
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256203
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-25 06:10:03 +00:00
Jens Johansen bba453b798 [parser] Record type type arguments
Fixes https://github.com/dart-lang/sdk/issues/49769

Change-Id: Icffa2dcfae95d950c00e72aa01121b6d6ebd147d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256065
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-08-24 08:25:38 +00:00
Jens Johansen cf8f47df4f [parser] Support RecordType for setter/getters and static methods
Fixes https://github.com/dart-lang/sdk/issues/49709

Change-Id: I710e687ce7e1066eef8439f541f2e5fe2771db36
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255988
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-08-24 07:42:51 +00:00
Johnni Winther 6751831ac6 [parser] Add hasNamedFields parameter to endRecordType
This makes it possible to handle named record fields without peeking
at the last record field (list) on the stack.

Change-Id: I96e2009cf5933ef505459ac8722d5bcbeb67db83
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255983
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2022-08-23 15:43:10 +00:00
Jens Johansen 38e5b8f9e0 [parser] Parse Record Types
This is the first stab at implementing the record types from
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Change-Id: I15c07e05c32a95206d177521c5f2b7fed69b4fbc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255244
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-19 07:04:44 +00:00
Jens Johansen 8a1dbb160f [parser] Parse record literals
This is the first stab at implementing the record expressions from
https://github.com/dart-lang/language/blob/master/working/0546-patterns/records-feature-specification.md

Change-Id: I2adb6cb3cd50d4ee45e144e86ec7011d046f6170
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253783
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-08-16 06:36:36 +00:00
Jens Johansen 183863e5bf [parser] More recovery of await in non-async context
Fixes https://github.com/dart-lang/sdk/issues/49116

Change-Id: I6b3f4bd88b17da5703dc268df413b3e5bb2e7d87
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249605
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-06-29 07:11:06 +00:00
Jens Johansen 25dcfca3c2 [parser][CFE][analyzer] Function is builtIn keyword
This CL makes `Function` a builtIn keyword instead of a `pseudo` keyword.

See also (and fixes):
https://github.com/dart-lang/sdk/issues/45703
https://github.com/dart-lang/sdk/issues/45704
https://github.com/dart-lang/sdk/issues/45705
https://github.com/dart-lang/sdk/issues/49197

This undoes https://dart-review.googlesource.com/c/sdk/+/195761

This is ~a merge of https://dart-review.googlesource.com/c/sdk/+/195906
and https://dart-review.googlesource.com/c/sdk/+/200080

Change-Id: I8bfee6976d43819fa355de99b3b2429eb67a7cdd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249484
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2022-06-28 14:26:33 +00:00
Jens Johansen b3917f7d5b [parser] Parse nullable type correctly after is/as when followed by '{'
E.g. nullasble cast last in initializer list followed by constructor
body.

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

Change-Id: I28633762444048b5e26b4b8343494302544344df
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249602
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-06-28 12:43:03 +00:00
Jens Johansen 7052965647 [parser] Parse nullable type correctly after is/as when followed by '}'
Fixes https://github.com/dart-lang/sdk/issues/48999

Change-Id: I42d7ec4110bb2cd212afbf7aae694f6a867b4423
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249601
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-27 08:42:51 +00:00
Johnni Winther 36607d877a [parser] Support 'augment super' as its own expression
This adds support for parsing `argument super` as its own expression
in augmentation libraries. This is not handled (correctly) by the
ast builders of analyzer and cfe yet.

Change-Id: Ibe67ad9daf56c82e8ec94f16d468e6b0d8f84d22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244922
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-05-20 09:36:52 +00:00
Johnni Winther 815ef172a8 [cfe] Add ParameterBuilder and FunctionTypeParameterBuilder
Adds ParameterBuilder as a common interfaces for FormalParameterBuilder
and the new class FunctionTypeParameterBuilder which is used for
parameters in FunctionTypeBuilder.

Change-Id: I5b7fb5a7d0b71547fe1b7a11261a5c783db99caa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239313
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-03-31 13:04:34 +00:00
Jens Johansen 6969a6edd3 [parser] Don't leak a rewrite when swallowing an error
The old code tries to determine something by using a forwarding listener
without forwarding to anything. It leaked a rewrite though, meaning that
the rewrite stayed, but the error given when rewriting wasn't passed on.

When then parsing it with the real listener, the rewrite was in effect
and there was no error to report. In total no errors were reported.

This fixes the issue by undoing any rewrites in this situation.

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

Change-Id: I5342ae6969f00dea830fb7abb30f21932907b8bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/236540
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-10 18:43:46 +00:00
Jens Johansen f40d76d360 [parser] Recover missing () for enum constant with type arguments or dot
Fixes https://github.com/dart-lang/sdk/issues/48380

Change-Id: I4f6fd7311c46ad45ccce5bf6b97b40932a457851
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234360
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-09 12:40:35 +00:00
Konstantin Shcheglov 9dc81176ab [parser] Better recovery on empty named argument name
Fixes https://github.com/dart-lang/sdk/issues/48288

Change-Id: I831b4870ba7dc69436f68e1ef84e0cdf258073a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234289
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-03-09 09:55:44 +00:00
Johnni Winther fa05359f2f [cfe] Support augmentation library imports
This adds support for the `import augment <uri>` import syntax when
the 'macros' experiment is enabled.

The CL also include propagation of the augment modifier on class methods
which was missed in a previous CL.

Change-Id: Ic843e7e34559bcac728c810590f34b727b5f7090
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234401
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-28 11:42:34 +00:00
Jens Johansen 514f678199 [parser] Better recovery for extra stuff in enum and using enum as identifier
Fixes https://github.com/dart-lang/sdk/issues/48371

Change-Id: I93331485c884c89c179c2fa332f3f975db9507f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234043
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-25 09:35:25 +00:00
Jens Johansen cc1366ee73 [parser] Update expect files after commit race between two parser changes
The two changes cd41e43c48 and
468f939428 had a "commit race".

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

Change-Id: Iaf72045bafbfc95af018eb187f06dc9d7359dc22
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234240
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-24 10:42:53 +00:00
Jens Johansen 468f939428 [parser] Better recovery for missing comma in initializer list.
Fixes https://github.com/dart-lang/sdk/issues/48411

Change-Id: I5212b15cf9f8749653dbced1c86d0e3e9c163d98
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234041
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-02-23 18:12:32 +00:00
Johnni Winther cd41e43c48 [parser] Support 'augment' as a built-in identifier for augmentation libraries
This changes the way the 'augment' modifier is handled in the parser.
Instead of being special cased for class declarations, it is now a
built-in identifier recognized only when the scanner is configured to
support augmentation libraries.

The change supports the used of the 'augment' modifier on not only
class declarations but also mixin and member declarations, as needed
for supporting macros.

Change-Id: I2679d198dea360900cfc478fae9c1660702a8a02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233887
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-23 16:17:42 +00:00
Chloe Stefantsova c12238d3ac [cfe] Allow typed super parameters
Part of https://github.com/dart-lang/sdk/issues/47525

Closes https://github.com/dart-lang/sdk/issues/47741
Closes https://github.com/dart-lang/sdk/issues/48444
Closes https://github.com/dart-lang/sdk/issues/47951

Change-Id: If9aadd996414df5091fc667a7202aafa9a0213db
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233889
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-02-23 13:10:33 +00:00
Johnni Winther 2435848b13 [parser] Support 'augment' modifier on class declarations
This adds support for the 'augment' modifier on class declarations
needed for the static meta-programming prototype.

Change-Id: Iadd11f766a195076405f2803b2092199caf1ea8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233180
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-02-18 09:39:23 +00:00
Jens Johansen a066e2c83e [parser] Don't be overly aggressive when parsing 'on' in 'try'
Fixes https://github.com/dart-lang/sdk/issues/47541

Change-Id: Idb25f86801b14f75fe7bc06e5496c6fdd2cbe971
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230243
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-31 09:09:35 +00:00
Jens Johansen c2b2aa5b9a [parser] Add beforeSynthetic to Synthetic*
Follow-up to https://dart-review.googlesource.com/c/sdk/+/205799

Change-Id: I620bf4548095d0597b89e4b6305c2301bcbed144
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/230242
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-01-28 08:54:13 +00:00
Johnni Winther 8cdc0e6474 [analyzer,cfe] Add support for macro class
This CL add the 'macros' experiment and adds support for the `macro`
modifier on class declarations. This is part of the prototyping of
the static meta-programming feature.

Change-Id: Ie4b8c5443fda3813307ea076c315baad6a90c3e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224205
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-12-21 10:45:59 +00:00
Chloe Stefantsova 7359264b13 Revert "[parser] Add support for typed super-initializer parameters"
This reverts commit fc9f7e3372.

Reason for revert: breakages in ternary operators involving super access.

Original change's description:
> [parser] Add support for typed super-initializer parameters
>
> Part of https://github.com/dart-lang/sdk/issues/47525
>
> Closes https://github.com/dart-lang/sdk/issues/47741
>
> Bug: https://github.com/dart-lang/sdk/issues/47741
> Change-Id: I0558b33aa43cc73e67ca0d17bd5c8ec1afdc526f
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221634
> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/47741
Change-Id: I565faadeb0776a089853dc2264af50b069e16056
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/222301
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2021-12-07 18:52:49 +00:00
Chloe Stefantsova fc9f7e3372 [parser] Add support for typed super-initializer parameters
Part of https://github.com/dart-lang/sdk/issues/47525

Closes https://github.com/dart-lang/sdk/issues/47741

Bug: https://github.com/dart-lang/sdk/issues/47741
Change-Id: I0558b33aa43cc73e67ca0d17bd5c8ec1afdc526f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/221634
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-12-06 10:31:57 +00:00
Chloe Stefantsova 312eb812c8 [parser][analyzer][cfe] Add parsing support for enhanced enums
Part of https://github.com/dart-lang/sdk/issues/47453.

Change-Id: I3a722cbcca6323b751eb3b2429bb9ffb642972b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217011
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2021-12-03 17:05:39 +00:00
Chloe Stefantsova 46cf1b9dd6 [parser][analyzer][cfe] Add parsing support for super-parameters
Part of https://github.com/dart-lang/sdk/issues/47525

Change-Id: I7b824e5e3fc9dbb2c6416dfd15df274037a8e9e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/219521
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-11-19 16:56:07 +00:00
Johnni Winther 44e35b1daa [cfe] Check for misplaced type arguments on implicit creation expression
Change-Id: Ic3436f2bce0369d0efad9946cbbdae7c6bf334b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218400
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2021-10-28 19:21:39 +00:00
Chloe Stefantsova a666b5a72b [analyzer,parser] Check for named before positional in analyzer
Since the check or the absence of the check for a named argument
appearing before a positional parameter is feature-specific
considering the language feature that allows placing the named
arguments anywhere, it should be performed by the listeners of the
parser and guarded by an experiment flag, in alignment with other
experimental featuers. This CL moves the check and the reporting of
the error from the parser into the Analyzer, so that later this check
can be skipped if the corresponding experiment flag is enabled.

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

Change-Id: Ib795d418af429ee04ecfff6dfa71ec1e836fe798
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216640
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Chloe Stefantsova <dmitryas@google.com>
2021-10-14 13:25:23 +00:00
Sam Rawlins 20da76f9f8 Update parser to allow unnamed constructor reference in comment reference
Code like `/// See also [List.new].` will be accepted as a valid comment
reference.

Test in front_end, analyzer, analysis_server.

Remove TODOs in analyzer for reporting a reference to an element whose
library is not the library in which the comment is found.

Bug: https://github.com/dart-lang/sdk/issues/47446
Change-Id: Ifa19278f92ac003082b62b121c66f0559c0152e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216583
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-13 14:09:26 +00:00
Johnni Winther cf1591f935 [cfe] Refactor detection of instance type variable access in static context
NamedTypeBuilder is now created with a state that determines whether it
can validly be resolved to an instance type variable.

Change-Id: I1e7f5f8e05a5f68ec18a063476b6cda291a1aca8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214643
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-10-05 11:58:04 +00:00
Jens Johansen 497a331365 [parser] Set 'recovered' in more cases
Fixes https://github.com/dart-lang/sdk/issues/47009
Fixes https://github.com/dart-lang/sdk/issues/47008

Change-Id: I4d00e378ad7cfe3b84fe0f48b11cb83ad7a14fc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/212826
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2021-09-10 08:18:17 +00:00
Dmitry Stefantsov ab508bb2d1 [cfe] Add basic parsing support for extension show clause
Change-Id: I63847a06ff7370dd1b92fc6b4b706c684f15638e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209909
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-09-07 10:35:12 +00:00
Jens Johansen 1231e3dad4 [parser] Better error message for >>> when not enabled in some cases (part 2)
https://github.com/dart-lang/sdk/issues/46886

Change-Id: I6195ad921f5c4b9622c735cb919c2d88f957f374
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211820
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-09-01 11:12:28 +00:00
Jens Johansen 5caa4365d7 [parser] Add beforeSynthetic to SyntheticStringToken
E.g. if reporting a missing ";" after a SyntheticStringToken (e.g. a
inserted identifier) before this CL it would go to the next token and
say we expected the ";" after that, when really we expected it *before*
that token.

Change-Id: I2c358e017edb2f661e307eba03dddaee889086d9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205799
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-30 11:56:30 +00:00
Paul Berry 1b4f067e0b Parser: Reduce the set of disambiguation tokens for resolving < ambiguities.
When the parser encounters a `<` after an expression, it must choose
whether to interpret it as a relational operator or a <typeArguments>
selector.  The disambiguation rule is: if the `<` and the tokens
following it *can* be parsed as <typeArguments>, and the token that
follows is a member of a privileged set of tokens, then it is treated
as a <typeArguments> selector; otherwise it is treated as a relational
operator.

This change reduces the privileged set of tokens to the following:

- the "continuation tokens" `(`, `.`, `==`, and `!=`
- the "stop tokens" `)`, `]`, `}`, `;`, `:`, and `,`

The names "continuation tokens" and "stop tokens" reflect the
rationale for choosing these tokens:

- Continuation tokens are tokens that we can reasonably imagine a
  programmer wanting to place after a type argument selector to
  *continue* the expression.  For example, `if (List<int> == T) ...`
  is allowed.

- Stop tokens are tokens that can't possibly follow a `>` that is a
  relational operator, because they *stop* the expression that's in
  progress.  For example, `var x = List<int>;` is allowed.

If a user wants to follow a <typeArguments> selector with a token
other than the ones above, they'll have to parenthesize the
expression.  So for example, if they want to do `List<int> + 1` (which
could be meaningful if an extension method defined `operator +` for
the type `Type`), they will have to use parentheses, and instead write
`(List<int>) + 1`.

Bug: https://github.com/dart-lang/language/issues/1806
Change-Id: I2816cdac24e55eac3cb3e9920e276404c1228d46
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210941
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-08-27 14:56:16 +00:00
Johnni Winther 3be0f377a5 [cfe] Update parser test expectations after parser change
Change-Id: I207fc18ce8add110e405bdc407906d0925ae2eb1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211440
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-26 13:42:28 +00:00
Johnni Winther ce4e7705f2 [cfe] Handle explicit instantiation in implicit creation syntax
Closes #46719
Closes #46887

Change-Id: I4ad0f1bb4ab847a44f749113c6446f62a474143c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211260
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-08-26 11:59:48 +00:00
Jens Johansen 72de10d938 [parser] Better error message for >>> when not enabled in some cases
https://github.com/dart-lang/sdk/issues/46886

Change-Id: Ib204d0c9a7116aaff0f0079be51d551c3f89316d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/211003
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2021-08-26 10:58:20 +00:00
Jens Johansen 7399e4e631 [parser] Recover differently when formal parameter name is keyword
Fixes https://github.com/dart-lang/sdk/issues/46736

Change-Id: Ia8ee921e14ac80934f9d0ec14e0140b23cc7d3bd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210725
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-23 15:14:47 +00:00
Jens Johansen b977476ca0 [parser] Add test for formal parameter with name that is keyword
Change-Id: If3256128bd7ad4c6062e3ea24f35e6a0552740a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210722
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-23 08:42:28 +00:00
Jens Johansen 01212e3262 [CFE] Add a parser test with triple shift disabled
Change-Id: I4c4bc51ae6f115f700ed5feea69a334213dedace
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/210560
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-19 12:01:25 +00:00
Jens Johansen 7bf731a547 [parser] Special-casing of '}' (like eof) wrt. looksLikeName
Change-Id: I55fb4c10931831630f9c1621addef7fbe9d5a9d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205797
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2021-08-19 06:41:58 +00:00
Paul Berry 8dc6c5ecb0 Allow is or as to follow type arguments in constructor tearoff disambiguation.
Fixes #46888.

Bug: https://github.com/dart-lang/sdk/issues/46888
Change-Id: I780a53a2d5a45a8630935c9be5c886d96ef1a2ef
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209881
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-08-13 15:41:31 +00:00
Jens Johansen a38e0a5087 [CFE] Parser test token-stream-dump writes synthetic text for SyntheticStringToken
E.g.
```
class A {
Stream<List<*synthetic*>>
(){}}
```

instead of
```
class A {
Stream<List<>>
(){}}
```

Change-Id: Ied8825f324582abbf3d2330d567801b63418df8b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/205788
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-07-06 12:11:35 +00:00