Johnni Winther
23f09803e2
[cfe] Mark pattern variables as having a declared initializer
...
Closes #51710
Change-Id: I204ec4b671835b8d51056871ab89365d9afb78b5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292702
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-04-03 10:08:46 +00:00
Johnni Winther
7914382b50
[cfe] Remove length check from map pattern matching
...
In response to https://github.com/dart-lang/language/pull/2960
TEST=existing expectation tests
Change-Id: I5c0d9070b98074c167dea0a0b9a0d576d4aa33d3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291825
Reviewed-by: Slava Egorov <vegorov@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-03-30 11:26:08 +00:00
Johnni Winther
2528bf8666
[kernel] Add VariableDeclaration.isHoisted
...
This flag is set when a variable declaration is moved earlier in
order to be available for subsequent code that couldn't contain
its declaration. For instance variables declared in patterns which
needs to be declared before the matching expressions that initialize
them.
TEST=existing expectations tests
Change-Id: I80ab1138f08f725f3e01905c1a57a1483f809328
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291820
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
2023-03-30 07:13:40 +00:00
Johnni Winther
61ee486e8c
[cfe] Use value for contains check in strong mode
...
Closes #51833
Change-Id: I6159e4bb7aba82c4bd1e44097e54d2fd86bb88a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291543
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-03-29 12:14:08 +00:00
Chloe Stefantsova
f27548aa5a
[cfe] Coerce expressions in pattern assignment and declaration RHS
...
Closes https://github.com/dart-lang/sdk/issues/51738
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: I4d496c303b1762c7234d66436daf125e69a34316
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291068
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-03-27 10:01:53 +00:00
Chloe Stefantsova
cfe9932a9e
[cfe] Make pattern matching error a StateError
...
This is the first step in adjusting the runtime error raised on a
pattern mismatch in an irrefutable context. For now, the error message
isn't specialized and doesn't reflect the nature of the mismatch.
Part of https://github.com/dart-lang/sdk/issues/51720
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: Ie4b997a1a36e92b25f1372f4dd98941dbcc08b61
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290842
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-03-23 16:10:16 +00:00
Johnni Winther
04e6f4c282
[kernel] Add VariableDeclaration.isSynthesized
...
This adds an [isSynthesized] flag to the [VariableDeclaration] the
signal when the variable doesn't correspond to a variable in the
source code.
The name of a variable can only be `null` if it is synthesized.
Partially in response to
https://github.com/dart-lang/sdk/issues/51554
TEST=existing
Change-Id: I94591971f11da09d210c8b25a2d05e22ca05dc62
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/286961
Reviewed-by: Joshua Litt <joshualitt@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Alexander Markov <alexmarkov@google.com >
2023-03-10 11:13:36 +00:00
Johnni Winther
f343c3ceb7
[cfe] Split cached expressions by receiver type
...
This splits cached expression by receiver type such that the initializing
expression for a cached variable isn't stored in the late variable
initializer, if it can be obtained in different ways. For instance having
both a list pattern and a map pattern in the same switch will trigger
caching of the .length property but obtaining expression differ base on
the receiver type, in the first case List.length and in second case
Map.length.
Closes #51138
Closes #51140
Change-Id: Ic4d8ca394a872113114514f72274413b836fdfb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280081
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-01-30 16:31:50 +00:00
Johnni Winther
68c326f455
[cfe] Refactor pattern matching generation
...
This enables caching during matching.
Closes https://github.com/dart-lang/sdk/issues/50934
Closes https://github.com/dart-lang/sdk/issues/50987
Change-Id: Iae1d8e0989029a193ba77f58338890d9bfa0c09f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279384
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-01-25 08:33:38 +00:00
Johnni Winther
c1bb19d002
[cfe] Fix lowering encodings
...
Cleans up some missing promoted variable gets and temporary
variables that were incorrectly marked as final.
Change-Id: I26412efe2dbb45b807ad6aba7f67c27981b1619c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279011
Reviewed-by: Jens Johansen <jensj@google.com >
Commit-Queue: Johnni Winther <johnniwinther@google.com >
2023-01-16 10:13:44 +00:00
Chloe Stefantsova
4b1eba51eb
[cfe] Handle rest patterns in map patterns
...
Part of https://github.com/dart-lang/sdk/issues/49749
Closes https://github.com/dart-lang/sdk/issues/50886
Change-Id: Ie44c35030aa3e74ab0b65f2e0abd0c5fb207976e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/278501
Reviewed-by: Johnni Winther <johnniwinther@google.com >
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
2023-01-07 00:09:45 +00:00
Chloe Stefantsova
f1ce203361
[cfe] Add desugaring of simple cases of pattern variable declaration
...
The late variables aren't supported in this CL.
Part of https://github.com/dart-lang/sdk/issues/49749
Change-Id: Iebc50f716e3575c6dd7bce915e5e294d4c8c8363
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/276525
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com >
Reviewed-by: Johnni Winther <johnniwinther@google.com >
2022-12-23 09:30:39 +00:00
Johnni Winther
e6d59342ff
[cfe] Build PatternVariableDeclaration in BodyBuilder
...
Change-Id: Ic55dbc03bf2cf4865275b186266c0f420263d406
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273744
Commit-Queue: Johnni Winther <johnniwinther@google.com >
Reviewed-by: Jens Johansen <jensj@google.com >
2022-12-13 17:03:13 +00:00