Commit Graph

7103 Commits

Author SHA1 Message Date
Kallen Tu ab217c355f [analyzer/cfe] Add an experiment flag for sealed class.
Have a separate flag from patterns, even though sealed families are to be shipped with patterns -- keep the work separate for now.

Change-Id: Ic3996b81d9a61f2a3b1e5137e7cc32ecc8bdec9e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267289
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Kevin Moore <kevmoo@google.com>
2022-11-05 00:20:50 +00:00
Konstantin Shcheglov 303d907237 Add Pattern type variable to TypeAnalyzer.
Change-Id: I3d88b0337689efecffac228c9acf03a5a52229d4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267461
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-11-04 19:23:37 +00:00
Chloe Stefantsova f01126211f [cfe] Implement the desugaring for NullCheckPattern
Additionally, fix the revealed variable declaration issues of
VariablePattern and change more remnant mentions of Matchers and
Binders.

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

Change-Id: I8f31bb1038f29768c82e0cfa4b55bfee3e0e16c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267581
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-04 12:40:26 +00:00
Chloe Stefantsova 51ad58d2fe [cfe] Allow inferred and aliased record types in opted-out libraries
Part of https://github.com/dart-lang/sdk/issues/50317

Change-Id: Icaed6443759a337769c4abaddd09b167f622db07
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267363
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-04 11:16:25 +00:00
Jens Johansen dda5ed11f9 [CFE] Fix potential null pointer crash in the incremental compiler
Crash seen in https://github.com/flutter/flutter/issues/114672

Change-Id: I647cbc97aefee7702ca5c14f4b8999cfc444db49
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267920
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-11-04 11:03:14 +00:00
Chloe Stefantsova 523257ab8a [cfe] Add license headers to the patterns testcaes
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I61cd83124083f2e017101be3ea020e04583023e3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267600
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-11-04 09:20:19 +00:00
Johnni Winther 2794cb9e17 [cfe] Check redirecting factory patches
In response to https://github.com/dart-lang/sdk/issues/49898

Change-Id: Ib87fb7558f85e9d8b956f1946e1e5de062deca4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267500
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-11-03 16:26:44 +00:00
Alexander Markov 3afb674e52 [vm] Cleanup kernel format versioning from the VM
TEST=ci

Change-Id: I9116d0e60aa073733fee3ce523fb5cbc2fb692f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267440
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
2022-11-03 15:44:25 +00:00
Johnni Winther 05ff50e6ca [kernel] Add View and ViewType
These are needed for the 'views' feature. No nodes are created yet.

TEST=existing

Change-Id: I0c7a34e460a4d17bd39ee23e7aa6bd8851f4275e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266620
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-11-03 08:42:06 +00:00
Konstantin Shcheglov d27d206108 Add analyzeRecordPattern() to the shared TypeAnalyzer.
Change-Id: I10e582a32f60db8bba8acf1f9cc8578469c51f77
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267442
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2022-11-02 21:06:33 +00:00
Chloe Stefantsova 777d706914 [cfe] Implement the desugaring for RelationalPattern
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I8b1da2a3c3f25e5147a519cf3d05e3ac2e42f401
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267341
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-11-02 14:45:35 +00:00
Johnni Winther a42ccdb352 Reland "[cfe] Perform checks during top-level inference", take 2
This relands https://dart-review.googlesource.com/c/sdk/+/248141

Change-Id: I4f8f5c85a494c2244a802e189619334a51272eac
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267321
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-11-02 14:18:29 +00:00
Konstantin Shcheglov 45fb04020d Merge TypeOperations2 into TypeOperations.
Change-Id: I957192cc72385f70cdd038a2e38b4ca4a0606bb7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266804
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2022-11-02 14:11:28 +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
Johnni Winther 4ec71ad43b [cfe] Visit all nodes during top-level inference
This changes the way the CFE perform top level inference. Previously
the inference would try to visit only the nodes needed to compute the
resulting type. In particular, statements (for instance inside function
expressions) would never be visited during top level inference.

This approach didn't match the analyzer approach which always visits
the whole field initializer, including any function expressions.
This has lead to various issues in the wild:

  https://github.com/dart-lang/sdk/issues/49528
  https://github.com/dart-lang/sdk/issues/50351

And triggered the language issue:

  https://github.com/dart-lang/language/issues/1650

While the old CFE approach allowed for more complex field initializers,
without reporting a cyclic dependency, for instance

   var f = () { f(); };

it didn't fit well with the horizontal inference introduced in
the 'inference-update-1' feature, since this relies on full inference of
function expressions. For instance for

   T method<T>(T Function(String?) f) { ... }
   var a = method((o) => o?.length ?? 0);
   var b = method((o) => o != null ? o.length : 0);
   var c = method((o) { return o?.length ?? 0; };

the CFE wouldn't infer same type for `a`, `b` and `c`. Furthermore
it would skip the condition `o != null` in `b` because it "didn't need
the type" (it is known to be `bool`), missing that the condition
promotes `o` to non-nullable in the true branch, leading to reporting
an error on `o.length` for being a potentially nullable access.

For these reasons, the CFE is now changed to _always_ visit the whole
field initializer, during top-level inference, making it align itself
with the analyzer implementation.

Closes #49528

Change-Id: Ic409b42699bb0e986f9d041ccb894863c952edf7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/267061
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-11-02 10:45:52 +00:00
Konstantin Shcheglov bf9a9a7abd Add analyzeRelationalPattern() to the shared TypeAnalyzer.
Not sure if this is has much value in comparison to the existed
implementation in the analyzer.

We also have private implementations for extractor and record
patterns in the analyzer. I don't know yet for sure how (if) we will
share these, but if we do, it might be something like this one.

Change-Id: I86070bcf922a58fbf1087c7ab42c6eb5695c1475
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266861
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-11-01 22:56:25 +00:00
Johnni Winther 53a0047ef0 Revert "Reland "[cfe] Perform checks during top-level inference""
This reverts commit 0825c176c3.

Reason for revert: Unintended failures in top-level inference found.

Original change's description:
> Reland "[cfe] Perform checks during top-level inference"
>
> This relands https://dart-review.googlesource.com/c/sdk/+/248141
>
> Change-Id: If18551321ba4b079b90f2a2b45f1be79534e0382
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266623
> Commit-Queue: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>

TBR=cstefantsova@google.com,johnniwinther@google.com,dart-scoped@luci-project-accounts.iam.gserviceaccount.com

Change-Id: Ic2cbd16753d64b11246997106c429c4028c408ac
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266900
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-11-01 08:33:56 +00:00
Chloe Stefantsova 85a841e881 [cfe] Combine Matchers and Binders into Patterns
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I1400d854d722e8280b9d0d66c9e1630829542aa5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266682
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-31 16:18:23 +00:00
Chloe Stefantsova 676babf86e [cfe] Remove MatcherVisitor and BinderVisitor interfaces
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I586270f8da55cd0c9445f24c698c24142c357978
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266630
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-31 15:23:28 +00:00
Johnni Winther 0825c176c3 Reland "[cfe] Perform checks during top-level inference"
This relands https://dart-review.googlesource.com/c/sdk/+/248141

Change-Id: If18551321ba4b079b90f2a2b45f1be79534e0382
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266623
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-31 09:05:29 +00:00
Riley Porter 0b4376e3d1 Revert "[dart2js] Change default for canPerformGlobalTransforms to false"
This reverts commit 700b94eb04.

Reason for revert: Revert due to internal failures: b/256219908

Original change's description:
> [dart2js] Change default for canPerformGlobalTransforms to false
>
> Fixes the staticInterop type erasure issue in dart2js when compiling the
> sdk separately from the code being compiled. With this change, the
> Angular hello_world app runs successfully with the dart:html prototype.
>
> Change-Id: Iaf5071f0f05d4fe1d17349adce4f1ce494154b9c
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262842
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Riley Porter <rileyporter@google.com>

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

Change-Id: I42c5c1ff5eddb675354dbe0e719390df1656e281
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266306
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-10-29 00:14:21 +00:00
Srujan Gaddam 3c5b2d7534 [ddc] Add runtime type for @staticInterop
Seprates our runtime types for package:js into static and
non-static interop types, and adds subtyping rules for them.
Removes erasure from transformations.

Change-Id: I9f5f4a7d4d7a5b8435ba50bde206dcf5348f4cce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265185
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-10-28 18:07:38 +00:00
Chloe Stefantsova a1ee1f6c36 [cfe] Implement a desugaring for simple if-case statements
Part of https://github.com/dart-lang/sdk/issues/49749

Change-Id: I38c486d4982c9dbd5515c36eb8c38cc76ff09800
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265760
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-10-28 16:08:42 +00:00
Johnni Winther ae38d892b3 [cfe] Add RecordMatcher
Change-Id: I8ea9967304d38c75c4da677cecbb1810553f1896
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266382
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-28 12:02:27 +00:00
Johnni Winther 646921914b [cfe] Add MapMatcher
+ include textual representation of internal nodes in ast-to-text
to verify the encoding.

Change-Id: I3b4fd1327539fd6d2e5176daee2a8fb79dc3c6e7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266201
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-28 12:02:27 +00:00
Jens Johansen 57d0376d67 [CFE] Fix 'Found failures!' message not being last in weekly test
We delay the execution of the second leak test ("leak test alternative
invalidation") to ensure the first one has fetched pub packages and
avoid both of them trying to do the same thing at the same time, or one
thinking it has been done when it's not actually done yet etc). If this
is slow or there's a crash it waits for at most 10 minutes before
launching the second iteration.
In those 10 minutes, though, it can have started waiting for all other
tests to finish and once they have, if any failed, print the
"Found failures!" (and what has failed of those) mixed in with all the
output from the leak test.
Technically, if the other tests finished within the 10 minutes (they
won't) it might even make it look like there are no failures even if the
second leak tests fails.

This CL fixes the issue by first awaiting the start of the second leak
test before awaiting the finishing of all started processes.

Change-Id: Iaace924346aa2bb4b8c6e025bd53e95e6a414a34
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/266021
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-28 11:53:58 +00:00
Jens Johansen 47cb34d8b9 [CFE] Fix weekly bot #112
Change-Id: I35efbe3a409516b386980d65befb4ac835483c2b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264160
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-28 11:21:54 +00:00
Chloe Stefantsova a9a915ee7b [cfe] Report errors on private fields in records
Closes https://github.com/dart-lang/sdk/issues/50144

Change-Id: I7cbf2fd30773269b5f839299f948da719f3eecc4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263781
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-28 10:38:52 +00:00
Johnni Winther 41e04fc452 [cfe] Handle non-const records in const constructors
The initializer was built in an 'inferred' rather than a 'required'
constant context, meaning that it would be encoded as a declaratively
constant literal instead of a structurally constant literal.

Closes #50132

Change-Id: I58b995d879efd2ec374b711718b63ac8f122bcfc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262349
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-28 09:55:22 +00:00
Riley Porter 700b94eb04 [dart2js] Change default for canPerformGlobalTransforms to false
Fixes the staticInterop type erasure issue in dart2js when compiling the
sdk separately from the code being compiled. With this change, the
Angular hello_world app runs successfully with the dart:html prototype.

Change-Id: Iaf5071f0f05d4fe1d17349adce4f1ce494154b9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262842
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2022-10-27 18:54:30 +00:00
Johnni Winther b11dc51c0d [cfe] Handle function calls and null shorting on record types
Closes #50135

Change-Id: If25f01cf1c1749d48c05550df7de8bb381cbb245
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265740
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-10-26 14:44:56 +00:00
Johnni Winther 142bf69440 [cfe] Pass on guard in if-case statement
Change-Id: Ic7c201bd90b2cf67a2b7526fc4ac035b21f34cc6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265720
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-26 10:19:58 +00:00
Sam Rawlins 9896f1c647 Enable the unnamed-libraries experiment by default in 2.19.0
TEST=tests/language/library/unnamed_library_test.dart

Bug: https://github.com/dart-lang/language/issues/1073
Change-Id: I1c7fa7b4ee4450e344a7613525765e4ab590cc8c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/265381
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Michael Thomsen <mit@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2022-10-25 21:10:57 +00:00
Srujan Gaddam 8c62ad7596 [pkg:js] Validate createStaticInteropMock
This revisits the validation after the redesign. The changes from
before the redesign include:
- Accounting for multiple extensions on @staticInterop classes
- Users can implement any of the extension members for a given
export name, with the exception that if there is a getter/setter
pair, both should be implemented if any one of them are
- Since this validation goes on top of exports, the Dart class
needs not be processed, and we use the same export creation process
to create the mock

Change-Id: I05a7cff765d6d37d3955dd93676e2d55d2b201b3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262862
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-10-24 17:37:09 +00:00
Srujan Gaddam 7f93985005 [pkg:js] Add validation for @JSExport and createDartExport
Creates an external createDartExport function in js_util.

Adds a number of checks for the annotation:
- Classes with the annotation should not have value in the annotation
- Classes with the annotation should have at least one instance member
somewhere in the hierarchy
- There are no export name collisions that are unresolvable accounting
for overrides
- Members with this annotation are instance members with a body only

Also adds checks to createDartExport:
- Checks that the type is a Dart class
- Checks that the type is marked as exportable

Change-Id: I52f27275966e9603e88921ce7897b7615178c4d2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259511
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2022-10-24 17:37:09 +00:00
Srujan Gaddam 877713882c [pkg:js] Add @JSExport annotation
For use with createDartExport. Adds comments describing the basic
use of this annotation.

Change-Id: I7744b6732054e845bf405c2d64e7e458c36deab7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260742
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-10-24 17:37:09 +00:00
Chloe Stefantsova 7179750fae [cfe] Report error on Object member names used as record field names
Part of https://github.com/dart-lang/sdk/issues/50143

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

Change-Id: I3ad99c6bbf27fcb5f4868f74d5005a9483081627
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263740
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-10-21 19:49:37 +00:00
Chloe Stefantsova f0c24c0af6 [cfe] Report errrors on duplicated names in record types
Part of https://github.com/dart-lang/sdk/issues/50143

Change-Id: I8c4acc9e5d36b2d5c7b9dbabbe4433d7e5efb4a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263400
Auto-Submit: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-21 19:11:51 +00:00
Johnni Winther 8995807b2b [cfe] Create various matcher in the body builder
This add the Expression-, Binary-, Cast-, NullAssert-, NullCheck-, List-
and RelationalMatcher and creates these during body building. The
IfCaseStatement is added to support propagation of these to the
inference visitor.

Change-Id: Ia9add15e504cb06af711efc1697a00b8e235e1a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263128
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-21 14:01:02 +00:00
Lukas Klingsbo 6e4e12922a DateTime copyWith extension
This change has been discussed for 8+ years and it would of course be preferred
to be added as an instance method, but since that is a breaking change I added it as an extension as discussed here:
https://github.com/dart-lang/sdk/issues/24644#issuecomment-1241695835

Change-Id: Iebb9f300e449920ae8891abac88f30b271321661
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258541
Commit-Queue: Lasse Nielsen <lrn@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
2022-10-20 10:50:25 +00:00
Paul Berry d9a5551af9 Front end logic for field promotion.
This is the common front end implementation of the new field promotion
feature (https://github.com/dart-lang/language/issues/2020).

There is no behavioral change yet unless the user activates field
promotion by enabling the experiment flag `inference-update-2`.

Change-Id: I0d1e0893af862c3af8a0ef4ea10e803606d48d7e
Bug: https://github.com/dart-lang/language/issues/2020
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260451
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-10-19 14:53:51 +00:00
Srujan Gaddam 521cbcdd47 [pkg:js] Disallow external extension members with type parameters
Bug: https://github.com/dart-lang/sdk/issues/49350

Checks to see that external extension members on `@staticInterop` types
do not declare or use a type parameter.

Change-Id: Id8646b599094b748c5490810b64d872065676014
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254103
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-10-18 17:47:29 +00:00
Srujan Gaddam b6526beeab [pkg:js] Disallow staticInterop generative constructors
Fixes https://github.com/dart-lang/sdk/issues/48730

Change-Id: I4c7f687ec8d2724de0e031aa5ebe887f93843761
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/254101
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-10-18 17:47:29 +00:00
Paul Berry cf50ee8eb4 Prototype integration of shared type analysis logic with CFE.
This change replaces the InferenceVisitorImpl.visitSwitchStatement
with a call to the new shared type analyzer, and implements the
necessary callbacks to allow analysis to work end-to-end.

Change-Id: I73a9514428b4ce092762d3ea450545986d0e1ea9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257491
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2022-10-18 14:33:18 +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
Jens Johansen 27e0e84cc3 [parser] Allow parsing top-level getter called get that's async/async*/sync*
Change-Id: I07e9759cdf61e1b633bbc0e7cd961d80ecfedf8e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263129
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2022-10-14 11:21:48 +00:00
Jens Johansen 7aeda010bf [parser] Follow-up on feedback posted after land of record commit
Follow-up to https://dart-review.googlesource.com/c/sdk/+/262605

Change-Id: I5178f7118af30eaa280dde746ddbf579fff5df40
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/263127
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jens Johansen <jensj@google.com>
2022-10-14 10:57:39 +00:00