Johnni Winther
f583a2bf73
[parser] Fix error reporting on const ()
...
The parser wrongly flagged any `const (...)` in a constant pattern
context and not just the intended `const ()`.
Closes #51415
Change-Id: Id7b0621cda4a144ac186dea55dbcbeaf041349bf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/283602
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-02-16 11:35:28 +00:00
Johnni Winther
0937087af8
[parser] Improve error recovery for constant patterns
...
This allows the parser to parse constant patterns at lower precedence
level in order to recognize more expressions in this context. To
support this, _parsePrecedenceExpressionLoop special cases a few cases
that should _not_ be parsed as expression in a constant pattern context.
Closes #50996
Change-Id: I43bb0ce52d366bd2dfcf47e12eec5883402f668a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/282100
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
2023-02-15 13:49:37 +00:00
Johnni Winther
d4a73e3b82
[cfe] Report errors on invalid const patterns with explicit 'const'.
...
Change-Id: I4f5994fd1f0d5e5289684e0da2f03720706f6d28
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/281840
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-02-15 10:34:28 +00:00
Johnni Winther
d89ae3c2c6
[parser] Report error on invalid const patterns
...
This handles the restriction imposed on the expression occurring
within a constant pattern.
Change-Id: I946d85f908609340a61e060c6bdbee143666fd91
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280460
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-02-09 12:43:31 +00:00
Jens Johansen
76e2c48428
[parser] Support record type in variable pattern
...
When seing a '(' after a var/final in `parseVariablePattern` require a
type --- the only allowed thing is a record type, but we can't
generally allow for instance `() async =>` as a record type as that
normally means something else.
Fixes #51230
Bug: https://github.com/dart-lang/sdk/issues/51230
Change-Id: I2e4797595b545d4cb726e36ce4e70a4d775e7e25
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280720
Commit-Queue: Jens Johansen <jensj@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Paul Berry <paulberry@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
2023-02-06 09:12:54 +00:00
Chloe Stefantsova
621398da84
[cfe] Add Listener.handleSwitchCaseNoWhenClause
...
This is to unify treatment of the variable scopes in switch cases.
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I14eb6dd55f69e294f99c5a820f000b0c4ef1f430
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280420
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
2023-02-03 01:00:39 +00:00
Jens Johansen
ee32255b21
[parser] Support record type in pattern
...
Fixes http://dartbug.com/51169
Fixes http://dartbug.com/51176
Change-Id: Iaa38585ce311319f2f4c106fc979c99d931eaa15
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280106
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Reviewed-by: Paul Berry <paulberry@google.com >
Commit-Queue: Jens Johansen <jensj@google.com >
2023-01-31 18:24:42 +00:00
Kallen Tu
ca974e5c4f
[analyzer/cfe] Reland: Parse final class modifier.
...
Reland same files as https://dart-review.googlesource.com/c/sdk/+/278090
The only major change is parser_impl.dart parsing changes for 'final'
This change should allow 'final' for classes and mixins and maintain prior final behaviour for other constructs such as enums, typedefs, or the breaking line which was 'final library = ...;'
Change-Id: I3d84fc47479f39df6d5b0dcbe8f92d1fb78a826a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279076
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Kallen Tu <kallentu@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
2023-01-19 16:08:28 +00:00
Kallen Tu
ed1157acc4
Revert "[analyzer/cfe] Parse final class modifier."
...
This reverts commit 2f1372b460 .
Reason for revert: Breaks the build. Unsure if there are other affected failures.
Original change's description:
> [analyzer/cfe] Parse final class modifier.
>
> Change-Id: Ia554c4f8f9617cc883a472eeb819aab2fd849077
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278090
> Reviewed-by: Johnni Winther <johnniwinther@google.com >
> Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
> Commit-Queue: Kallen Tu <kallentu@google.com >
TBR=scheglov@google.com ,johnniwinther@google.com ,kallentu@google.com ,dart-scoped@luci-project-accounts.iam.gserviceaccount.com
Change-Id: I5dd74202bd46d69b7261d6d30d8cf3b1a40dbc99
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279040
Reviewed-by: Jake Macdonald <jakemac@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
2023-01-13 21:04:01 +00:00
Kallen Tu
2f1372b460
[analyzer/cfe] Parse final class modifier.
...
Change-Id: Ia554c4f8f9617cc883a472eeb819aab2fd849077
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278090
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Kallen Tu <kallentu@google.com >
2023-01-13 19:16:20 +00:00
Kallen Tu
4aaf1a2cb1
[analyzer/cfe] Parse base and interface class modifiers
...
Change-Id: I52f8ac53ec504b4c1d07c04744b4b079a1163dfd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277721
Commit-Queue: Kallen Tu <kallentu@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
2023-01-12 18:47:39 +00:00
Jens Johansen
82e1b443a6
[parser] Recover when there's space between metadata and parenthesis
...
In https://dart-review.googlesource.com/c/sdk/+/272600 the change to
disallow spaces between metadata and parenthesis is the parenthesis
is supposed to be arguments for the metadata. Recovery was requested
on that CL and this is it.
Change-Id: I26c809f09cf8411365a2b758f635a494e7ebbd49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278516
Commit-Queue: Jens Johansen <jensj@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
2023-01-11 07:56:47 +00:00
Chloe Stefantsova
e925066175
[cfe] Adjust scoping for variable patterns in switch expressions
...
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I32f3ebf6c45afbbdc291d8f919b14266b646b998
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278347
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-01-05 15:49:44 +00:00
Chloe Stefantsova
4a8c6fa480
[cfe] Support guards and multiple heads in pattern switch statements
...
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I6c0dcd4bd2cb7921c27168b71f61f1793c8b2a12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278182
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-01-05 11:36:28 +00:00
Johnni Winther
dffa3191b9
[cfe] Handle case const
...
This push the constant context for constant patterns such that
the constness is propagated to subexpressions.
Closes #50629
Change-Id: Idcb279765c5464ba17abb98b3f9eb852a7c87b96
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277860
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-01-04 13:37:54 +00:00
Chloe Stefantsova
40a7c7cec0
[cfe] Support guard clauses in if-case statements
...
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I2988ba4dda65b4e54282f892fa377cffed70f25c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/277984
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-01-03 17:34:18 +00:00
Jens Johansen
6bce0d6b7a
[parser] Breaking change for metadata parsing
...
https://github.com/dart-lang/language/blob/master/accepted/future-releases/records/records-feature-specification.md#ambiguity-with-metadata-annotations
Change-Id: I47e584868f2a12a2553cbd57e3e5b8fbacaa5f27
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272600
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Jens Johansen <jensj@google.com >
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com >
2022-12-20 11:22:58 +00:00
Kallen Tu
120bfdc076
[analyzer/cfe] Parse 'mixin class' behind sealed flag.
...
Allow 'mixin class' modifier which allows a class to be used as a mixin.
https://github.com/dart-lang/language/blob/master/working/base-interface-final/feature-specification.md
Change-Id: I6b4dac75f2ff09b7ef833c5e015b1baf7fa3883b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275144
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Kallen Tu <kallentu@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
2022-12-14 15:41:58 +00:00
Paul Berry
38cab10852
Patterns parsing: track when variable patterns are in an assignment context.
...
Variable patterns behave so differently inside a patternAssignment
that we may want to represent them using different AST nodes inside
the analyzer/CFE. This change adds a boolean flag allowing the
implementation to know what kind of variable pattern it's looking at
when parsing occurs.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I60adf2865bbe24f85b72a79b1360833bf823bd67
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273829
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
2022-12-07 22:45:40 +00:00
Paul Berry
7a3aa5c7f5
CFE parser test cases for metadata in for-in loops with patterns.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I336b391c9102e4e6dd3eabce1051763e3bc797d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273621
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-12-05 14:56:41 +00:00
Paul Berry
e9a1248fc2
Add parser support for patterns in for-in statements and collection elements.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I9eda03c1501cf3164cfb09cf9084576a5d1141cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273122
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-12-02 15:22:38 +00:00
Paul Berry
c381425bd3
Parser: additional fixes to mayParseFunctionExpressions for patterns.
...
Expressions can also occur in patterns, either after an equality or
relational operator (e.g. `== e`), or after `const` (though what's
allowed after `const` is heavily restricted). We need to make sure
that the expression parser doesn't greedily treat `=>` as introducing
a function expression when parsing these constructs inside a switch
expression.
But it's ok to allow function expressions inside list patterns, map
patterns, parenthesized patterns, and in the argument part of object
patterns. (These will be rejected by a later stage of analysis
because expressions inside of patterns must be const, and a function
expression can't be const. But the parser should still accept them so
that we can give useful error messages).
Fixes #50591 .
Bug: https://github.com/dart-lang/sdk/issues/50591
Change-Id: I828555782f5bc8cb8aae8a3948849b7a75bdec57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273286
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-12-02 15:04:09 +00:00
Paul Berry
882941caf4
_fe_analyzer_shared: add support for rest patterns with subpatterns in maps.
...
The parser now handles maps that contain rest patterns with
subpatterns (e.g. `{'foo': _, ...var rest}`). Even though this is
invalid Dart, it still makes sense for the parser to handle it so that
we can generate higher quality error messages.
The shared type analyzer now generates an error,
`restPatternWithSubPatternInMap`, if it encounters this error
condition.
Change-Id: I7f447bde28e646593aa432e3e5ad1f5e415bdd30
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273283
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
2022-12-02 13:50:38 +00:00
Paul Berry
599911d197
Add parser support for for (var pattern = expression; ...; ...)
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I5f07b848ba06be403e56538a4cc64f6de51bd668
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273005
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-12-01 21:49:47 +00:00
Paul Berry
b0c705e4bd
Set mayParseFunctionExpressions properly during switch expression parsing.
...
We need to prohibit function expressions during guard clauses in
switch expressions, otherwise the `=>` might be misinterpreted.
Fixes #50591 .
Bug: https://github.com/dart-lang/sdk/issues/50591 , https://github.com/dart-lang/language/issues/2672
Change-Id: Ie5703ac7049557798b19778281429e8a591cf09f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273020
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-12-01 18:57:33 +00:00
Paul Berry
43c68f90ed
Add parser support for && and || in patterns.
...
Previously, the implementation used `&` and `|` for logical-and and
logical-or patterns. That is being changed to `&&` and `||`.
As a first step, we add support for `&&` and `||`, without removing
support for `&` and `|`. In a follow-up CL I'll update existing
tests, and then after a day or two I'll remove support for `&` and
`|`. This should avoid conflicts with other patterns work that's in
progress.
Bug: https://github.com/dart-lang/language/issues/2501
Change-Id: I2d5dc158248160d84e9f0889f5de390b999cbc7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272861
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
2022-11-30 23:16:45 +00:00
Paul Berry
701a0d289f
Add support for expression statements beginning with a map pattern.
...
Bug: https://github.com/dart-lang/sdk/issues/50035 , https://github.com/dart-lang/language/issues/2662
Change-Id: Ifb141cf563848fc0035423a625e27585cce2ea57
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272523
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
2022-11-30 15:18:43 +00:00
Paul Berry
9d0bca98e9
Rework computation of precedence for patterns.
...
Previously, we boosted the precedence of `as` inside patterns, to make
it higher than `|` and `&`. Now, we reduce the precedence of `|` and
`&` to match that of `||` and `&&`.
The new approach should make it easier to transition to using `||` and
`&&` in patterns.
Bug: https://github.com/dart-lang/language/issues/2501
Change-Id: I6658484860ef809bc9029fa75747fdd7ce986836
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272700
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
2022-11-30 05:12:47 +00:00
Paul Berry
7b41b6215b
Add parser support for patternAssignment.
...
Bug: https://github.com/dart-lang/sdk/issues/50035 , https://github.com/dart-lang/sdk/issues/50502 , https://github.com/dart-lang/sdk/issues/50575
Change-Id: Idd3bdcae7cbb95c6f2016bb5d3efc638867f52af
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272383
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-29 20:16:29 +00:00
Paul Berry
2a9491b613
Rename looksLikePatternVariableDeclaration.
...
The new name, `looksLikeOuterPatternEquals`, is a more precise
description of what it does.
This helps prepare for adding parser support for pattern assignments,
which require the same functionality.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: Ibfcc4c37faac1770c98a427facdffda5c40e6d08
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272344
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-28 21:33:41 +00:00
Paul Berry
a3befd399a
Add support for ... inside map patterns
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I350eb526e67e4cc42c94b4776e5d38315932ddc5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272382
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-28 18:34:58 +00:00
Paul Berry
f22c4580e4
Fix patterns parsing when EOF encountered during potential pattern variable declaration.
...
Fixes #50563 .
Bug: https://github.com/dart-lang/sdk/issues/50563
Change-Id: Icc1e38c0775bd1fab7ed717f24932dea47dd2990
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/272342
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-28 16:36:08 +00:00
Paul Berry
fe087f24d1
Add parser support for switch expressions.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I0c58664d44312f5e9d61d24e34e7cd26dbee3a9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271740
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-23 23:04:12 +00:00
Paul Berry
15c8f286d7
Fix parsing of single identifier patterns before when.
...
There's already logic for addressing similar issues before `as`; I
just had to generalize it.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I09d9c69cd291fe8bc3ebea8181f632ddca0c49e8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271580
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-23 16:47:29 +00:00
Paul Berry
ff18485f72
Add parser support for ... in list patterns.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I31c7003fd40a6e074f2561561d2fba49955cc098
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271565
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-23 15:11:50 +00:00
Paul Berry
0037c6c001
Rename extractorPattern to objectPattern in parser and listeners.
...
This reflects a spec change that was done in
https://github.com/dart-lang/language/commit/4c83abe1fe34686c113772148c2bd32a82e8ae0f .
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I282ec073d723294b7c1cd84928d8404a50b0b195
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/271162
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-22 23:06:10 +00:00
Paul Berry
ef4f5a3470
Add parser support for patternVariableDeclaration.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I13158547d9200f37eb4434d1792b4d4667a46071
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270920
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-21 18:33:05 +00:00
Paul Berry
a975bf0737
Parser API changes in preparation for supporting patternVariableDeclaration.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I2661b7cbe60815b6232a165d56a478d8975aa6c2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/270228
Reviewed-by: Jens Johansen <jensj@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-11-21 14:30:16 +00:00
Paul Berry
1af3f76a6c
Patterns parsing: fix handling of builtin identifiers and pseudo-keywords.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I95f2b7d59a54d0d5e1975bd8cd1dce88db03fa51
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/269580
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
2022-11-14 14:12:48 +00:00
Kallen Tu
835317d7da
[cfe] Add initial parser support for sealed classes.
...
Basic support for the `sealed` keyword and added a few tests.
Change-Id: I5adedda22b1e8ce6d4b61136ad8e6d38bdf05043
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/268366
Commit-Queue: Kallen Tu <kallentu@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
2022-11-09 17:39:59 +00:00
Johnni Winther
5baa4af7d8
[analyzer,cfe] Add 'views' feature and support for 'view class'
...
This adds the 'views' feature flag together with parser support
for 'view class'. If the feature is not enabled, an error is reported.
TEST=pkg/front_end/parser_testcases/views/...
Change-Id: I813ac86a0e7de9f0a5729c6d7ae35b82d1258ae5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265780
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
Reviewed-by: William Hesse <whesse@google.com >
2022-11-02 11:09:59 +00:00
Paul Berry
5e29849393
Parser: consolidate handleCaseMatch and endCaseExpression.
...
There was no need for both of these listener callbacks, because they
were always called together. Since `beginCaseExpression` is actually
used, it makes sense to keep `endCaseExpression` and get rid of
`handleCaseMatch`.
Change-Id: I544096b2c2b2814e8cc0c8606455855cb77c9e60
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264102
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-10-15 13:51:59 +00:00
Paul Berry
9aab3c7746
Patterns parsing: add support for guards.
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I21db09c9d8c1d359e1b125eea2bae2749cdb72fd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264101
Reviewed-by: Jens Johansen <jensj@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-10-14 20:14:20 +00:00
Paul Berry
4cf63fb382
Parser and listener API changes for supporting pattern guards.
...
These are in their own CL so that it's easy to verify that no
functionalty has changed, even though a lot of parser expectations
files are affected.
In a follow-up CL, I'll add code that actually parses pattern guards.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I79f5a02df45e29b69aa4d8348cfdf27042ada9d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264020
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-10-14 15:42:12 +00:00
Paul Berry
5923b883db
Parser: add support for wildcard patterns.
...
The bare identifier `_` is treated as a variable pattern wherever it
appears, even though other bare identifiers are sometimes treated as
constant patterns.
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I475ef627b6d0bf519a1972aa5ec683e2d032f02b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263280
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
2022-10-14 14:04:59 +00:00
Johnni Winther
b7debf00f7
[cfe] Handle pattern events in BodyBuilder
...
This supports pattern listener events in the BodyBuilder without
crashing. Currently no AST is created and only dummy objects are put
on the stack.
Change-Id: I24a29073b578bb9aaa07e84d5177e51428074a94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262422
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2022-10-04 13:31:41 +00:00
Paul Berry
118f628ecf
Patterns: add support for parsing constant patterns
...
Bug: https://github.com/dart-lang/sdk/issues/50035
Change-Id: I601248bc206d9b19521b020fadb2eccd048e0ec7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261701
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Paul Berry <paulberry@google.com >
Reviewed-by: Konstantin Shcheglov <scheglov@google.com >
2022-10-03 19:46:16 +00:00
Johnni Winther
dc7df3218e
[cfe] Add parser tests for patterns
...
These tests are copied from
pkg/analyzer/test/generated/patterns_parser_test.dart
Change-Id: Ib5fd7ca8c22dd24bf5334ac87140d961bc80838a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261660
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
2022-09-29 09:08:57 +00:00