Commit graph

2145 commits

Author SHA1 Message Date
Johnni Winther 911b376f7e [cfe] Handle inline class representation field in object pattern
Closes #52667

Change-Id: I9c6d51597ff27ae3a7cdeed29d75755c18a2d530
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311742
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-07-10 11:02:50 +00:00
Chloe Stefantsova b36fbaef2c [cfe] Update both sides of intersection types in GUB
In computation of GUB both the left-hand and the right-hand sides of
the intersection should be updated as nullable when the other operator
to GUB is Null.

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

Change-Id: I4b616a94a3e7bf149205ba1b90732453c19ace47
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311845
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-07-10 09:51:56 +00:00
Nicholas Shahan be6a560ca1 [kernel] Fix record type equivalence
- Increment index to avoid infinite loop when the first named elements
  in the two record types are equivalent.
- Add some test cases for record types.

Fixes: https://github.com/dart-lang/sdk/issues/52817
Change-Id: Ifbf3505c74a1f130c9c90ddbb6b1d96d9641e51e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311929
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2023-07-06 16:37:49 +00:00
Johnni Winther 0c8ded72dc [cfe] Add FileUriConstantExpression
This adds FileUriConstantExpression, a subclass of ConstantExpression, to support correct file offset of annotations for augmentations and patches.
The FileUriExpression is used to carry the file uri of the expression
before constant evaluation.

TEST=general/patch_annotations

Change-Id: I0dc8a0cb97dd530fd1960785d38c2d5e4883c3dd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/311660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-28 07:52:09 +00:00
Johnni Winther 545b7c02f7 [cfe] Support redirecting factories in inline classes
Closes #52525

TEST=inline_class/issue52525

Change-Id: Ia2f6e3aa92ddd053f5736150713d9267b89f401c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308621
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-14 10:31:42 +00:00
Johnni Winther 7226c7245e [kernel] Remove RedirectingFactory node
Closes #28421
Closes #29169

TEST=existing

Change-Id: Iee7d84fadc10981648cb327589fd7aa15b9b3e12
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308140
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-14 06:38:32 +00:00
Johnni Winther 90d5a99c15 [cfe] Remove redirecting factory field
TEST=existing

Change-Id: Ic9f51693d0cc75cbe745dcaa0f4feb26d7005a9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307941
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-13 09:24:28 +00:00
Johnni Winther c308c9327d [cfe] Ensure Member.isInlineClassMember is set
TEST=existing

Change-Id: I16fbeb0bbe431e3f85ed11c21e0506e6aa4abf58
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302206
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2023-06-08 15:02:03 +00:00
Johnni Winther 82e3a751a9 [cfe] Remove unnecessary_null_comparison code
The frontend is now run with sound null safety so these are no longer needed.

TEST=existing

Change-Id: I6c1776845854695ff34e310a3bb5bc9d86715f06
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307901
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-06-08 08:46:47 +00:00
Johnni Winther ccb21bd54b [kernel] Add RedirectingFactoryTarget to FunctionNode
This replaces the RedirectingFactoryBody with a dedicated
RedirectingFactoryTarget object on FunctionNode.

TEST=existing

Change-Id: I3cc8b9f8abf938c6d60fdbc91b1f4210686fc359
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307082
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-08 08:04:15 +00:00
Johnni Winther 36641368bb [cfe] Treat NonNullableByDefault as default in ast-to-text
This changes ast-to-text to mark legacy libraries instead of
non-nullable-by-default libraries.

TEST=existing

Change-Id: Ib01147e4ef48c2c5b2ffc6b23547998344dfdf2e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307121
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-06-08 06:28:50 +00:00
Alexander Markov 5ff0821b27 [kernel,vm] First-class kernel serialization of FutureOrType and NullType
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/52565

Change-Id: I9906f2d10c7ed51d11a0c402b51c8189ac3b6298
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306901
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
2023-06-05 21:24:35 +00:00
Johnni Winther 8091581e72 [cfe] Use unchecked AsExpression instead of promoted VariableGet
This changes the pattern lowering to use unchecked AsExpression
instead of promoted VariableGet when this occurs within a late
cache variable initializer. This is done to avoid promoted variables
that violate the (otherwise used) conservative reasoning about the
execution order of closures.

The unchecked AsExpressions are now shown in the ast-to-text.

Change-Id: I4fa6813f3b5cc73d9cdac17054de59e5d4b8ce7d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/307044
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
2023-06-02 16:37:17 +00:00
Johnni Winther 5476e3bd6e [kernel] Rename InterfaceType.className to classReference
+ Name.libraryName -> libraryReference

Change-Id: I25b5022ea87f92fb5837f03d29f1671f0e68261b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304740
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2023-06-01 06:43:46 +00:00
Chloe Stefantsova 9fecc29dbb [cfe] Adjust the resulting nullabilities in 'flatten'
Closes https://github.com/dart-lang/sdk/issues/52485

Change-Id: I428933193611ffc68c750e6dc91f54ee2385036b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/306400
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-05-31 07:33:37 +00:00
Sam Rawlins f292b20dfd Replace deprecated lint rules in front-end packages
Two rules, `iterable_contains_unrelated_type` and
`list_remove_unrelated_type` are deprecated (which fails the CI) and
replaced with `collection_methods_unrelated_type`.

See https://logs.chromium.org/logs/dart/buildbucket/cr-buildbucket/8780614474452305057/+/u/analyze_pkg_/stdout for the failures resulting from referencing deprecated rules.

Change-Id: I00087e684bfb230b5dc94ab832c969ed67a631f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/304780
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-23 14:01:49 +00:00
Johnni Winther 4d37cc40ff [cfe] Support redirecting initializers in inline classes
Closes #52119

Change-Id: Id9322ba7c4571786c8c07b6a36c3b1e3ef94aec9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303740
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-05-17 12:35:07 +00:00
Jens Johansen 4fd173a43e [CFE] Various small optimizations
Looking at instructions this seems to speedup compilation of
`compile.dart` with about 1.00% in AOT mode.

Occasionally there's also a measurable time improvement, e.g.

```
msec task-clock:u: -1.3447% +/- 1.1644%
seconds time elapsed: -1.3438% +/- 1.1638%
seconds user: -1.8838% +/- 1.4478%
```

Change-Id: I98866740b00bc01c70dd82d7591864bcb278394d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303701
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-05-17 12:20:08 +00:00
Mayank Patke ea84221100 Fix nullability of cast to FunctionType.
Fixes: #52403
Change-Id: I6eeaad51f45b8dabfd61132d2deae0893b01e99b
Fixed: 52403
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/303420
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Auto-Submit: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-05-16 06:43:09 +00:00
Johnni Winther 0767670779 [cfe] Don't create tear-offs for sealed class constructors
Closes #52359

Change-Id: Iaa8d64f01978c201165242dd0b0a3b18890de833
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302920
Reviewed-by: Kallen Tu <kallentu@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-05-15 06:32:34 +00:00
Johnni Winther 9b42e2d166 [cfe] Generate covariant checks in pattern matching
Closes #52192

Change-Id: Iaac816273fb80eaf166fc300b2b3367f1a592d3f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/302223
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-05-09 11:02:45 +00:00
Johnni Winther 13c4ad23c5 [kernel] Add SwitchStatement.expressionType
This adds the static type of the switch statement expression to
the AST to better support optimizations based on the possible
runtime values of the switch expression.

TEST=existing

Change-Id: Ief35b687150401100d8c96721a026e9f0911b3b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301063
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2023-05-08 07:39:02 +00:00
Chloe Stefantsova e3275641a3 [cfe] Remove spurious ".this" in IntersectionType.withDeclaredNullability
Change-Id: Id5428658ebdccca4385a700725218ee5551495f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/300660
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-05-03 06:20:24 +00:00
Johnni Winther ff0079b94b Reland "[cfe] Enable verification in platform compilation"
This relands https://dart-review.googlesource.com/c/sdk/+/299100

The fix is in patchset 2

Change-Id: I505f3d9c67625cac24ecf60f0eb3d0617d2e847d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298821
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-05-01 07:35:41 +00:00
Johnni Winther cb7546f58d [cfe] Handle unevaluated constants in enums for exhaustiveness checking
If enum values have used defined fields that use fromEnvironment constants
the enum values themselves are seen as unevaluated constants when
compiling with dart2js. This means that the enum value are not recognized
correctly in exhaustiveness checking.

This CL changes the enum value representation of the CFE to use the
enum class and the name of the enum element, derived either from the
instance constant or the unevaluated constant expression.

Change-Id: I7d5791a41349dacd20b588f5dbfca37d8755ef79
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299100
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2023-04-28 06:52:59 +00:00
Jens Johansen d7b70f94e3 [kernel] Short-circut 'computeNonNull' when already nonNullable
When compiling "compile.dart" the type given to computeNonNull
is already non-nullable in ~42% of the cases, meaning it spends
time not doing anything.

Change-Id: I94598efceb3b46f0ac81ec36814c216d01a9e38b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298823
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-04-28 06:38:30 +00:00
Oleh Prypin 7bbf7ff43e Revert "[cfe] Enable verification in platform compilation"
This reverts commit 20e0ddf130.

Reason for revert: breakages in google3

Original change's description:
> [cfe] Enable verification in platform compilation
>
> Closes #32530
>
> Change-Id: I5a44e211a4b203e4879dbc8f6bf4bbec5abf51f3
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298820
> Reviewed-by: Jens Johansen <jensj@google.com>
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Nicholas Shahan <nshahan@google.com>

Change-Id: Idb2c30d93ad385431734c4a4e884d3d53be76b2b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/299040
Commit-Queue: Alexander Thomas <athom@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Reviewed-by: Oleh Prypin <oprypin@google.com>
Auto-Submit: Oleh Prypin <oprypin@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-04-27 08:43:00 +00:00
Johnni Winther 20e0ddf130 [cfe] Enable verification in platform compilation
Closes #32530

Change-Id: I5a44e211a4b203e4879dbc8f6bf4bbec5abf51f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298820
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2023-04-27 07:34:39 +00:00
Johnni Winther 009cbfbeac [kernel] Merge front_end and kernel verifiers
This merges the front_end and kernel verifiers into one Target based
kernel verifier. The RedirectingFactoryBody work-around is moved to
package:kernel to support its verification.

TEST=existing

Change-Id: I0adf4d2c22c4009cf439b3b23fa14192253a2846
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/280161
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2023-04-26 14:14:36 +00:00
Jens Johansen 43b499cf9a [kernel] Optimize computeThisFunctionType
When compiling compile.dart:
148,192 FunctionType are created via `computeThisFunctionType`.
133,085 of them have no named parameters; 141,507 of them have no type
parameters; 128,357 of them have neither.

This CL makes it not create new lists when not needed
(or create empty iterators and sort empty lists), and makes the lists
it do create not growable.

Change-Id: Ibd5fef458b8a1254aa2f1fab80d0449a2f0bfd94
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298541
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2023-04-26 11:29:28 +00:00
Jens Johansen dc77baa5a8 [kernel] Call Reference.node less; make it inlinable
This CL splits up `Reference.node` in to the most-often fast-case and the
has-to-load case, making the procedure smaller which makes the VM inline
it. This was "verified" by looking at the VMs optimized flow graph for
`Reference.asClass`.

This CL furthermore reduces the number of "calls" to `Reference.node`
by almost half (a reduction of over 3 mio calls when compiling
`compile.dart`) by "caching" the `.node` call in the `as*` methods.

Change-Id: I7b5497397a11f05fdeaf05d6cc420072d98dc030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298101
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2023-04-25 10:21:46 +00:00
Johnni Winther fe01a2068d [cfe] Implement least upper bound for inline types
Closes #51556

Change-Id: I44f2ae947b5316d21d23b39b88f1515702525955
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294983
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-04-24 09:14:07 +00:00
William Hesse 7bac8ed687 [Release] Bump minor version of main to version 3.1.
Change-Id: Icf489686d790be195e37db37727782227d2f3704
TEST=Version bump autogenerated by scripts
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/294600
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: William Hesse <whesse@google.com>
2023-04-12 16:36:20 +00:00
Nate Biggs 2551fa9b62 [kernel] Add option to skip including source bytes in dill file.
There is an `includeSources` option today to skip writing both source bytes as well as the line starts. Dart2JS needs the line starts to generate source maps from its modified dill. But the actual bytes aren't used passed a certain point. This new option would allow us to exclude the information we don't need from the dill.

For large applications this can reduce the size of the dill by close to 50%.

Change-Id: I5e69370ee30b2fb856320c346b12662893cb595b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/293761
Reviewed-by: Jens Johansen <jensj@google.com>
2023-04-11 15:20:43 +00:00
Johnni Winther b1ca1ee51d [cfe] Update flatten handling of type variables
In response to https://github.com/dart-lang/language/issues/2326

Change-Id: I8cba5cf1f0ce1d78f4472e7a8dc1009182023341
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/274440
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-04-05 14:07:59 +00:00
Chloe Stefantsova c747272f1f [cfe] Report mismatching joint variables on the first use
Closes https://github.com/dart-lang/sdk/issues/51929

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

Change-Id: Ib20bdb5eb9b0b5c1e8b34cfbac6498e642350875
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292782
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-04-04 11:56:48 +00:00
Johnni Winther af8eee9960 [cfe] Use required type for object patterns
This uses the required type instead of the lookup type for object
patterns to ensure that extension members are accessed correctly.

Change-Id: I05b4765f1fa3f85acd005a0484349b467cff7c9f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/292703
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-04-03 10:53:44 +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 f9dbe6bef4 [cfe] Use unary minus for negative int literals
Closes #51761

Change-Id: I48b72f44c6a7f5dd69f76e5006b1f8b3bebca353
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/291462
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-28 12:29:58 +00:00
Johnni Winther b126fad7c4 [cfe] Handle negative length in list/map pattern
Change-Id: Ifb3fbace24ca8d20fce48327c85bb1c4a92054f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290523
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-24 09:24:25 +00:00
Johnni Winther 210275c1fe [cfe] Use AsExpression for AssignedVariablePattern lowering
The lowering previously used a PromotedCachableExpression, therefore
missing the needed check on assignment.

Closes #51432

Change-Id: I9e671326df25add9a8abea03d1e52b1be5740adc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289901
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-24 00:10:07 +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
Chloe Stefantsova 472968cda7 [cfe] Fix the subtyping case of FutureOr and RecordType
Closes https://github.com/dart-lang/sdk/issues/51731

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

Change-Id: Ie726f2f768df47fd00bd88af1f970ee3a86bf0a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/290526
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2023-03-22 17:03:17 +00:00
Johnni Winther 5493d42be3 [cfe] Throw error for null in non-nullable switch in weak mode
This adds thrown exception in weak-mode for exhaustive switch
expressions and statements to catch the unsound `null` values.

Closes #51769
Closes #51053

Change-Id: Ieb89e65f51e84853510fc320b64db01a80a262ec
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/289600
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-22 10:30:24 +00:00
Johnni Winther 7cc2553fa1 [_fe_shared_analyzer] Use real exhaustiveness checking algorithm
This changes the analyzer and CFE to use the real exhaustiveness
checking algorithm. The fallback algorithm is kept and will be
removed once we know that the real exhaustiveness algorithm sticks.

Change-Id: Ic9df92c1ca9f7dec4cbdfa138dc6ed39ef2d4df5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288703
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-17 16:45:35 +00:00
Johnni Winther 712930e834 [cfe] Remove ConstantEvaluator.libraryOf
Instead of finding the current library through the parents relation
we use the static type context which already had access to the
library.

Change-Id: Ia2116160b24b701ffa0794b9ccc9a59506c3adc0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288840
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-16 13:37:19 +00:00
Johnni Winther c62534fc03 [cfe] Clean up properties on Pattern classes
This removes the "unset" values and uses nullable types instead.
The names and uses of the pattern fields are normalized, using
`matchedValueType`, `requiredType` and `lookupType` consistently
between [Pattern] subclasses.

TEST=existing

Change-Id: Ic79ce17075aa8ce252e1c223b59bef660f32bb7c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288704
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2023-03-16 11:43:58 +00:00
Johnni Winther 2d1f2abe0b [_fe_analyzer_shared] Add support for Object members on non-interface types
Change-Id: I0fb6cba760e6f0b2023a829b8e518e50b41451d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2023-03-15 17:33:38 +00:00
Johnni Winther 5e537e1cd2 [cfe] Integrate exhaustiveness checking into constant evaluator
This removes the use of [SwitchInfo], [SwitchCaseInfo] and
[ExhaustivessInfo] to pass on information for exhaustiveness checking
and instead uses the AST nodes directly in the constant evaluator.

Change-Id: Ie8d72b03e38334d1be9857794c38ed142dba5783
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288402
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-03-13 21:23:21 +00:00