Commit Graph

5428 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
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
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
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
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
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
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
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
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
Johnni Winther 49b0503702 [cfe] Reinstate access full access to Record when enabled by default
This reinstate the support for access Record from all libraries, opt-in
_and_ opt-out, when 'records' is enabled by default. This was wrongfully
removed in a previous CL.

Change-Id: Iede9257302754ca862edb5573203a251cb7bac9c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/261647
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-10-07 10:06:28 +00:00
Chloe Stefantsova fb0b4a80e6 [cfe] Allow records on the RHS of typedefs
Part of https://github.com/dart-lang/sdk/issues/49713

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

Change-Id: I482280599487a3539f88c715e5a92e78f810b264
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262962
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-10-06 15:03:00 +00:00
Johnni Winther c3de385658 [cfe] Unify handling of 'resolveTypeParameterType'.
We had multiple implementations of this logic and with the introduction
of IntersectionType some where not updated. Instead, this is now added
as a property of `DartType`.

Closes #50112

Change-Id: I2d7a3943b0577d905a1861aa35b0552578766993
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262960
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-06 10:38:39 +00:00
Chloe Stefantsova e77f2ee5ff [cfe] Account for class Record in constraint gathering
Part of https://github.com/dart-lang/sdk/issues/49713

Change-Id: Idfcc304c8da8bb1a6cd887de707ddfd060934543
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262427
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-10-06 08:21:38 +00:00
Johnni Winther e2bf48243f [cfe] Handle record access through type variables
... and promotions.

Closes #50124

Change-Id: Ie04db8c13f81e6d81ad12bf2677e924492ac5fc3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262602
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-10-05 09:25:21 +00:00
Johnni Winther 99f60a5e66 [cfe,vm] Support 'records' experiment in the sdk
This adds support for the experimental 'records' feature in the sdk
by settings its experimental release version to 2.19 and opting the sdk
into the feature the allowed_experiments.

Change-Id: I7a30212e5724e5d8ae3208f177103764b9aed737
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262760
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2022-10-05 09:00:30 +00:00
Johnni Winther 5b2e23eab0 [cfe,vm,wasm] Handle private injected members like augmentations
This changes the way the CFE handled private injected members. Previously
these were "hidden" within the patch library in which they were declared.
Now they are, like with members injected in augmentation libraries, fully
integrated and accessible within the origin library and all its patches.

This change revealed that the vm and wasm platforms had some
inconsistently declared classes in which injected private members that
were not implemented by all implementing classes. For these, throwing
stubs have been added.

Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try
Change-Id: I330eade944964ef43b83aa416baef75e3649d023
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262340
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-10-04 14:43:43 +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
Chloe Stefantsova 1d768f3c75 Reland "Reland "[cfe,corelib] Add class 'Record' to the core library""
This is a reland of commit 4b6a8f35b9

Original change's description:
> Reland "[cfe,corelib] Add class 'Record' to the core library"
>
> Part of https://github.com/dart-lang/sdk/issues/49713
>
> Change-Id: I56bfca49492d14bb561b32993fd9adfe775b7400
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259583
> Reviewed-by: Johnni Winther <johnniwinther@google.com>
> Reviewed-by: Slava Egorov <vegorov@google.com>
> Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>

Change-Id: Idaab98c028312ca36bd07f569374ca8b76151a02
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260101
Reviewed-by: Slava Egorov <vegorov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-10-04 12:29:47 +00:00
Chloe Stefantsova 7e57f6e371 [cfe] Implement pointwise implicit downcasts for record literals
This CL implements the adjustment of the static semantics for records
as described in
https://github.com/dart-lang/language/pull/2489/commits/d19f6d564457a1c3108e644e0eb6106b6418f987. The
adjustment is based on the discussion at
https://github.com/dart-lang/language/issues/2488.

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

Change-Id: I7a9d456f702ad0fb14aa3bd121ba9d2bbd104414
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262202
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Chloe Stefantsova <cstefantsova@google.com>
2022-10-04 11:41:45 +00:00
Johnni Winther 3931dc6b08 [cfe] Use reportIfNotEnabled in endRecordLiteral
Change-Id: I9a2bd53838a40419f9aa4779380488b547db5b39
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262421
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2022-10-04 09:30:07 +00:00
Johnni Winther b16e2aea54 [cfe] Ensure Crash.trace is printed when Crash is created directly
The Crash class was used for to conflicting purposes: 1) To encapsulate
a captured crash in the CFE, in which case the trace was printed
directly, and 2) To propagate a crash in the CFE together with the
context in which it crash, in which case the trace was not printed but
just included in the Crash object.

This CL adds a `_hasBeenReported` field to ensure that 1) is rethrown
as intended and 2) is printed and a Crash object of type 1) is returned.

Change-Id: I6efc752414158aad60867b5dbb8d799d5b08036a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/262420
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-10-04 07:20:18 +00:00
Johnni Winther 599836a2c5 [cfe,vm] Make patch parts into actual parts
This changes the VM patch files to use parts explicitly, making
handling of patch libraries similar to regular libraries.

Cq-Include-Trybots: luci.dart.try:dart2wasm-linux-x64-d8-try

Change-Id: I6280d62edba3d12a1f77ae6a7f64e1e9b5d18227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224949
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-09-30 15:25:11 +00:00
Johnni Winther 90dd21e5d0 [cfe] Use distinct import uri on patch libraries
This CL changes the import uri of a patch library builder to be its
file uri. This makes patch libraries more like regular libraries,
preparing for full support for patch parts.

Change-Id: I1fa4c10998f17945d6607e1307337b5f66992c3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/224947
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2022-09-29 14:28:57 +00:00