Commit graph

96 commits

Author SHA1 Message Date
Joshua Litt fea406591e [dart2wasm] Fix for tearoffs in allowInterop.
Change-Id: Ic753bb22af345e4825f2a142fa262504a562e7c4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/260283
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-22 03:04:17 +00:00
Srujan Gaddam ed38cc874d [pkg:js] Add proto argument to createStaticInteropMock
Adds optional argument proto to allow users to pass instanceof/is
checks with the generated forwarding mock.

Change-Id: If2dba386fb0e66cbe738105e58d9e5ec1f02d02a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257162
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-09-16 20:13:30 +00:00
Srujan Gaddam 69221fe62a [pkg:js] Create mock in createStaticInteropMock
Bug: https://github.com/dart-lang/sdk/issues/49351

After static checks have passed, adds functionality for a JS
object literal to mock a @staticInterop class using a Dart
implementation. Fields, getters, setters, and methods' names are
added to the object literal, and their values are closures which
call the Dart mock's members.

Change-Id: Ie2ef27179eb79039d3aa28737b246c5091f4beb6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257160
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-09-16 20:13:30 +00:00
Srujan Gaddam 8a081b95c6 [pkg:js] Add type/conformance checking for createStaticInteropMock
Bug: https://github.com/dart-lang/sdk/issues/49351

Adds checks for the following cases:
- Type arguments to createStaticInteropMock are correct
- No missing members in implementing class
- Inherited and non-overridden @staticInterop members are implemented
- Dart class can implement through inheritance and mixins
- Implemented members are correct subtypes of @staticInterop members
- Potential extension member conflicts that are attempted to be
resolved through subtyping rules

Change-Id: Iacbe5846040ba7fab41459aa19be77351cf1efca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/255761
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-09-16 20:13:30 +00:00
Ahmed Ashour 5fe480b788 Fix typos
Fix #49864

TEST=ci

Change-Id: I9a7e06d604cd0b4f56f2ac229ab3fc9f01cb9d76
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/256824
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Lasse Nielsen <lrn@google.com>
Reviewed-by: Liam Appelbe <liama@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2022-09-16 19:35:00 +00:00
Joshua Litt 8429f01593 [dart2wasm] Implement optional parameters for JS interop callbacks.
Also added tests of optional parameters for static interop functions.

Change-Id: Id23237b96d0de5a4a4b948b3f23fd1bfe40b218e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/259101
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-14 22:33:02 +00:00
Joshua Litt 6c36674dd8 [dart2wasm] Support returning ints from JS via static interop.
Change-Id: I20e08d9afcd567edf34de0cd9b9ad95a3e2663d7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258501
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-09-09 21:21:34 +00:00
Joshua Litt b04641f37d [dart2wasm] Fix @JS name parsing for factory constructors.
Change-Id: Iad6886a794b6ed5395177a3e45f69f10484fc703
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/258382
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-09 17:29:47 +00:00
Joshua Litt 708264289d [dart2wasm] Use WasmExternRef for JS interop.
Change-Id: I01138d48ba9cc67954ef086968af90dae173fda9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257880
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-07 20:55:27 +00:00
Joshua Litt eb540194ad [dart2wasm] Implement promiseToFuture.
Change-Id: I265441c5c78933f8bdace53f956d22677442d7fe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257803
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-09-07 17:56:17 +00:00
Joshua Litt b99140115b [dart2wasm] Fix some js interop related issues.
Change-Id: Id189c53c7a4c536c703b0b9e83265a81d0c14094
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253609
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-08-08 17:29:40 +00:00
Srujan Gaddam 61abaeda3f [CFE/web] Move static interop erasure and remove outline stubber
Deletes the outline stubber as it's not necessary on any backend.
DDC should compile the entire sources and outline dill in one step.
dart2wasm operates similarly, and so only needs the modular transformer.
dart2js moves the erasure to a global transform.

Also, this CL reverts now unnecessary plumbing that was needed for the
outline stubber.

Change-Id: Ic085c4fad5a6bdfc7d6916f7fa575c6ef9b20110
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/253000
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-08-01 18:17:44 +00:00
Joshua Litt f6f29df4b5 [dart2wasm] Enable RTI tests for oddball and interface types.
Change-Id: I4b92d4cf30779b78f3eab1acd18193fdd58ab452
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249641
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-07-23 00:56:38 +00:00
Srujan Gaddam f6a3d2d5c2 [pkg:js] Transform constants and supertypes in eraser
Types in constants and supertypes need to be visited in case
they include @staticInterop types.

Fixes a bug in caching in the constant replacer.

Change-Id: Icde8b7170a8806d6a1995cad57a9788893b7772f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249441
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-07-18 18:24:53 +00:00
Devon Carew ba805d3c63 [pkg] use package:lints for pkg/_js_interop_checks, pkg/js_runtime
Change-Id: I3bf78a773d431b21bd2f5cecaf6271899b73da70
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/250783
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Devon Carew <devoncarew@google.com>
2022-07-18 17:27:53 +00:00
Srujan Gaddam b372fd4c52 [CFE/pkg:js] Find reference of stub if it already exists
Fixes #49301

From https://github.com/dart-lang/sdk/issues/49301#issuecomment-1165536192

Adds referenceFromIndex to outline transformations so that the eraser
can use it to find the reference for the stub if it was already created.
This is needed when the module where the stub exists is invalidated.
Since references in other modules should still be valid, we should
attempt to get that reference.

Change-Id: I5905a002480444aecd57de650cd439bdc34d4eba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249729
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
2022-06-28 18:36:02 +00:00
Srujan Gaddam 911f3a8012 [pkg:js] Handle mutually recursive libraries
Related issue: #49301

We have an invariant to make sure stubs aren't created across other
libraries but really the invariant should test for other
components, as it's valid to have two libraries call each other's
factories. Similarly, stubs need to be added to the class before we
clone the body, as the body may mutually recurse. Tests are changed
to reflect this.

Change-Id: I529b682f107a55791a52fa79f082cc8ef5fce1f3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249546
Reviewed-by: Riley Porter <rileyporter@google.com>
2022-06-28 18:36:02 +00:00
Srujan Gaddam 459d57c8b8 [package:js] Add static interop stub for outlines
Fixes b/235393918

@staticInterop replaces factories with a new named node, a static
method. In order to persist this transformation in modular
compilation, this needs to be done to outlines that can then be
consumed by the source library. In order to allow erasure at the
time of 'performOutlineTransformations', coreTypes is added to that
API.

Change-Id: I90d17fff8bbe143982fcd12cfb06dc3e8d58781a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247928
Commit-Queue: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2022-06-17 19:58:49 +00:00
Johnni Winther 05bbe907d7 [cfe] Support extraneous references in serialization
This enables the serialization to handle references to libraries that
are not part of the serialized libraries. This is a step towards
removing the need to call computeCanonicalNames from outside the
serialization and to always use library filters for serialization
of a subset of the libraries in a component.

In response to b/235393918

TEST=existing

Change-Id: I48cd8b027795850ac2411a80e4b55efd517bb2cc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/248588
Reviewed-by: Jens Johansen <jensj@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-06-17 11:52:39 +00:00
Joshua Litt 76ccc89a10 [dart2wasm] Fix a number of minor JS interop issues.
This CL fixes a number of minor JS interop issues.
* `dartify` was moved to Dart, so we can control implicit coercion from JS
* All JS types are 'correctly' handled in `dartify` though a few are boxed
  as opaque types that could be exposed.
* The logic to convert a JS array is now driven from the Dart side.
* Function, Number, and Boolean can now make the roundtrip through Dart.
* The wrapper for Dart functions in JS is now a regular JS function.

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

Change-Id: Ifcd7a447419bca2adf78070e07750c1b3c5c6a18
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247925
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-06-14 17:32:39 +00:00
Joshua Litt 3fd96e2cb8 [dart2wasm] Wire up stubbed out dart:js on dart2wasm
Change-Id: Ia06db4b1b2f3d07278819936842a4185cc9a45f8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247329
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-06-08 20:38:52 +00:00
Joshua Litt d872e74a6d [js] Support js_util on Dart2wasm.
This CL consists of:
1) Moving most of the contents of `js_util_wasm_patch` to
   `js_util_patch` and `js_helper`.
2) Addressing the inconsistencies between `js_util` and `js_util_wasm`.
3) Fixing a minor bug with nested `allowInterop` in
   `js_util_wasm_optimizer`.
4) Removing hardcoded eval.

Change-Id: Ie43cdc91d344745ef9b40e273192b34af2a84138
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246380
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2022-06-06 18:18:20 +00:00
Sigmund Cherem e808fa1751 [jsinterop] Add static check for JSName of static class members.
Static class members could technically be mapped to a name with dots,
but in the early days of JSInterop we thought this was not necessary
since it could also be modeled as a top-level member or by adding
additional classes and exposing the member as a simple name on a deeper
class.

This invariant was assumed by DDC (which crashed if this was not the
case) and ignored by dart2js.

This change adds a static check to ensure both compilers act
consistenlty.

Fixes https://github.com/dart-lang/sdk/issues/27926

Change-Id: I20e59fbb75f0378a58ca88dc3910e079b4eeb7a3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/247180
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2022-06-03 17:02:26 +00:00
Devon Carew f7c46f145c [pkg] prefer 'any' deps for package dev dependencies
Tested: CI validation
Change-Id: If65cc156130a65ffe00c6f1660ac320e2921afae
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246053
Commit-Queue: Devon Carew <devoncarew@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
2022-05-27 01:34:59 +00:00
Johnni Winther 5222bfd90c [cfe] Refactor bounds checking
This CL moves the bounds checking into the TypeBuilder instead of
performing it from the outside on the computed DartType node.
This solves several problems:

  1) Errors are now reported on the type in the code instead of the
     declaration which holds the type.
  2) Checking of type aliases (both function and nonfunction type
     aliases) is now handled correctly in all cases. This achieved by
     computed the aliased type (containing TypedefType nodes)
     internally and performing the checking on this type, and only
     convert the type into the unaliased version (without TypedefType
     nodes) after checks have been performed. Previously this handled
     through the FunctionType.typedefType property for function type
     aliases and through and incomplete work-around for nonfunction
     type aliases.
  3) With 2) FunctionType.typedefType is no longer needed and is
     removed.

TEST=general/bounds_*

Change-Id: I7653bca5ccb0ebf4b3553828a298d1ad918ef235
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/243722
Reviewed-by: Mayank Patke <fishythefish@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2022-05-17 14:36:19 +00:00
Nate Bosch 6ebd2633cd Use any deps for all unpublished packages
It should not be necessary to ever run `pub get` for a package which is
not published. All packages used in the SDK are controlled by a single
package config, so it's not necessary to declare versions or paths for
any packages.

Remove all dependency overrides.

R=devoncarew@google.com

Change-Id: Icb328813b471f35ee4c99995f4e90aac4d8ed438
Tested: Covered by existing static analysis.
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/244767
Commit-Queue: Nate Bosch <nbosch@google.com>
Reviewed-by: Alexander Aprelev <aam@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2022-05-17 01:22:25 +00:00
Mayank Patke 091559359e Reland "[dart2js] Lower late field checks during SSA."
This reverts commit 45c1e51bb3.

Reason for revert: Reland

Original change's description:
> Revert "[dart2js] Lower late field checks during SSA."
>
> This reverts commit 7187b2efe9.
>
> Reason for revert: Broke flutter roll
>
> Original change's description:
> > [dart2js] Lower late field checks during SSA.
> >
> > Change-Id: I80e7a30c6f2a461e46b4f52ebf7eb7a13fbc6227
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240501
> > Reviewed-by: Stephen Adams <sra@google.com>
> > Commit-Queue: Mayank Patke <fishythefish@google.com>
>
> TBR=sra@google.com,fishythefish@google.com
>
> Change-Id: Idf4eff95425db4d770137d589d4bb5484fc6e187
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241806
> Reviewed-by: Mayank Patke <fishythefish@google.com>
> Reviewed-by: Nate Biggs <natebiggs@google.com>
> Commit-Queue: Mayank Patke <fishythefish@google.com>


Change-Id: Iccba8947a5778f5310e194d814b398dc46465fbb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241807
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
2022-04-21 21:10:58 +00:00
Joshua Litt 8e6fa91711 [dart2wasm] Add support for calling Dart functions from JS.
Change-Id: I83cb295ce61b266b86e9efa194dcbc61fc2c8d31
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239200
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-21 16:30:18 +00:00
Mayank Patke 45c1e51bb3 Revert "[dart2js] Lower late field checks during SSA."
This reverts commit 7187b2efe9.

Reason for revert: Broke flutter roll

Original change's description:
> [dart2js] Lower late field checks during SSA.
>
> Change-Id: I80e7a30c6f2a461e46b4f52ebf7eb7a13fbc6227
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240501
> Reviewed-by: Stephen Adams <sra@google.com>
> Commit-Queue: Mayank Patke <fishythefish@google.com>

TBR=sra@google.com,fishythefish@google.com

Change-Id: Idf4eff95425db4d770137d589d4bb5484fc6e187
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241806
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-04-20 18:37:18 +00:00
Joshua Litt 84497e41ca [package:js] Add @trustTypes annotation.
Adds an experimental `@trustTypes` annotation which can be used during
migration to static interop to preserve the older semantics for JS interop.

Change-Id: Ic00a6c968b15f8c8f5d0840b82db5a6670eaf0eb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241362
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-20 15:24:18 +00:00
Johnni Winther f26c0e2056 [cfe] Add explicit type argument to .map(...).toList()
Expressions like

  List<VariableDeclaration> variables = ...
  List<Expression> reads = variables.map((v) => VariableGet(v)).toList()

don't get the intended type argument `<Expression>` through inference,
but instead the type inferred from the return type of the closure, in
this case `<VariableGet>`.

This causes problems when used with the AST which assumes that
expressions are interchangeable wherever they are used, and is likely
the cause of https://github.com/flutter/flutter/issues/102077 .

This CL adds an explicit type argument in these cases.

TEST=general/infer_map

Change-Id: I0bcae21f06c54f290dc20686b0d84c065d8ea04c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/241605
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2022-04-20 06:56:58 +00:00
Mayank Patke 7187b2efe9 [dart2js] Lower late field checks during SSA.
Change-Id: I80e7a30c6f2a461e46b4f52ebf7eb7a13fbc6227
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240501
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Mayank Patke <fishythefish@google.com>
2022-04-19 19:01:27 +00:00
Joshua Litt bdbecf318e [dart2wasm] Add support for anonymous JS interop classes.
Change-Id: Ib0645b4e3b0bd410188be9e39755be5e4c02bb44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240323
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 22:51:02 +00:00
Joshua Litt fcba410c6c [dart2wasm] Add support for top level JS interop methods.
Change-Id: I2926306419f5694d180ce57d392b144a2e3177f7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240144
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 21:34:02 +00:00
Joshua Litt f6af76eaf8 [dart2wasm] Basic support for js interop annotations.
Change-Id: Ibb66415ec77a45e436d4058c5d9873c5918b68a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/239009
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
Commit-Queue: Joshua Litt <joshualitt@google.com>
2022-04-12 18:26:02 +00:00
Srujan Gaddam 3436650ccb Add OWNERS_WEB as owners of _js_interop_checks
Change-Id: I21c3c53eb268ccf326077bc7269be3949a7682b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/240200
Auto-Submit: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Alexander Thomas <athom@google.com>
Commit-Queue: Alexander Thomas <athom@google.com>
2022-04-05 10:41:23 +00:00
Srujan Gaddam f8933dda8d [pkg:js] Disallow all operators in JS classes
Closes https://github.com/dart-lang/sdk/issues/48515

Expands existing checks for index operations to all operators. This
only affects instance members and not extension members.

Change-Id: I8cbb5b12a49539ea502e4396e1b469ffb0e17d5e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/235980
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2022-03-09 01:48:24 +00:00
Nate Bosch 33e174084a Replace Uri.scheme == with Uri.isScheme
Use `hasScheme` in place of comparing against the empty string, and
`isScheme` to compare against all other schemes.

TEST=No behavior changes.

Change-Id: Ifc9fd13c6cf37933ebd4a754c4b500dedbcb291b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231185
Reviewed-by: Kevin Moore <kevmoo@google.com>
Commit-Queue: Nate Bosch <nbosch@google.com>
2022-02-08 21:38:57 +00:00
Srujan Gaddam aea4018aa6 [pkg:js] Filter synthetic procedures from static interop errors
Pre-null safety, `Object` procedures are synthesized in classes.
Since these are instance members, this triggers static interop
errors on all classes, so they need to be filtered out.

Change-Id: I5c66da6277c4d93c19cce930d54e933d842ecf85
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216560
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2021-12-10 18:36:00 +00:00
Srujan Gaddam 45c350052d [dart2js/ddc] Rename BaseJavaScriptObject to JavaScriptObject
Part 2 of the renaming to create the new parent type. Also modifies
some existing tests to reflect the change in name and function of
JavaScriptObject.

Change-Id: If37f34dd8477b7fc1fe459d3225ecf2537fb9f1a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217156
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-12-10 18:36:00 +00:00
Srujan Gaddam 758cb462f5 [pkg:js] Erase static interop types
Closes https://github.com/dart-lang/sdk/issues/47324

Erases static interop class types in favor of `BaseJavaScriptObject`.
Types are erased everywhere except for constructors, whose invocations
are instead wrapped with a cast. Constructor type erasure is avoided
to ensure the AST is still type-valid. Factories with bodies have
static stubs added instead, and tests are added for this change.

Change-Id: I7231aaaf32d22bc6261adb672a602e8a9e6c86a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215948
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Riley Porter <rileyporter@google.com>
2021-12-10 18:36:00 +00:00
Riley Porter 97e45b35be Use type parameter in extension member lowering
Pass through expected return type as the generic type
parameter for the js_util functions in the transformation
for external extension member lowering.

Change-Id: I7044c532a8b449003faa166edd8c09fe7fd794a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214461
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-11-04 23:58:46 +00:00
Kevin Moore 83286de2a8 Allow pub get/upgrade to run on a number of packages in pkg/
Zero runtime affect to these unpublished packages
Allows using standard tools such as dart test, etc
Also allows better checking of dependency constraints

TEST=no effect on SDK build process

Change-Id: Ic6fbe6ce8f57724a87c058eccad64ce8e7473af1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/218180
Auto-Submit: Kevin Moore <kevmoo@google.com>
Reviewed-by: Devon Carew <devoncarew@google.com>
2021-10-27 23:15:56 +00:00
Riley Porter d17fd4b14f Reland "Re-land "Add a generic return type for js_util functions""
This reverts commit b70a134933.

Reason for revert: google3 linter bugs disabled with a comment and Flutter PR with new js_util landed with ignore comments. Should be safe to reland.

Original change's description:
> Revert "Re-land "Add a generic return type for js_util functions""
>
> This reverts commit 66cbeb6718.
>
> Reason for revert: Causes dart analyzer and dart linter to find
> issues within google3 and flutter, causing breakages and blocking
> the roll.
>
> Original change's description:
> > Re-land "Add a generic return type for js_util functions"
> >
> > This relands commit 46486cf260.
> >
> > The differences from the original commit:
> >   - jsify is no longer being made generic
> >   - Updated the CHANGELOG
> >
> > Change-Id: Ibc3402833cce2babbec9a57ad73963d7b9442ed8
> > Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216920
> > Commit-Queue: Riley Porter <rileyporter@google.com>
> > Reviewed-by: Sigmund Cherem <sigmund@google.com>
>
> TBR=sigmund@google.com,srujzs@google.com,rileyporter@google.com
>
> Change-Id: Ic2ff63bc9658ccafcab3db75bdd06814d2f17b76
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216963
> Reviewed-by: Siva Annamalai <asiva@google.com>
> Commit-Queue: Siva Annamalai <asiva@google.com>

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

Change-Id: Ia8c753b568b0aca10e7784126048bddd9e1ab976
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/217148
Reviewed-by: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-10-18 18:41:53 +00:00
Siva Annamalai b70a134933 Revert "Re-land "Add a generic return type for js_util functions""
This reverts commit 66cbeb6718.

Reason for revert: Causes dart analyzer and dart linter to find
issues within google3 and flutter, causing breakages and blocking
the roll.

Original change's description:
> Re-land "Add a generic return type for js_util functions"
>
> This relands commit 46486cf260.
>
> The differences from the original commit:
>   - jsify is no longer being made generic
>   - Updated the CHANGELOG
>
> Change-Id: Ibc3402833cce2babbec9a57ad73963d7b9442ed8
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216920
> Commit-Queue: Riley Porter <rileyporter@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>

TBR=sigmund@google.com,srujzs@google.com,rileyporter@google.com

Change-Id: Ic2ff63bc9658ccafcab3db75bdd06814d2f17b76
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216963
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2021-10-15 03:40:28 +00:00
Riley Porter 66cbeb6718 Re-land "Add a generic return type for js_util functions"
This relands commit 46486cf260.

The differences from the original commit:
  - jsify is no longer being made generic
  - Updated the CHANGELOG

Change-Id: Ibc3402833cce2babbec9a57ad73963d7b9442ed8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/216920
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-10-14 22:56:45 +00:00
Srujan Gaddam 67be663490 [pkg:js] Add @staticInterop annotation to package:js
Adds @staticInterop annotation to allow users to declare static interop
classes. Also adds errors for erroneous usage of static interop
classes, like including instance members or using a non-static
supertype.

Change-Id: I21abafbf6ea6c2eb7cd0425f0a54c1ba35d6ec6c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215010
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2021-10-06 19:04:02 +00:00
Riley Porter 1332c63a4c Revert "Add a generic return type for js_util functions"
This reverts commit 46486cf260.

Reason for revert: Causes dart analyzer and dart linter to find
issues within google3 and flutter, causing breakages and blocking
the roll.

Original change's description:
> Add a generic return type for js_util functions
>
> Allows further optimization to pass along return type
> information and remove extra AsExpression casts.
>
> Change-Id: I87aef171887e3f9af4c80003ff284eb2503d0cdb
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214460
> Reviewed-by: Srujan Gaddam <srujzs@google.com>
> Reviewed-by: Sigmund Cherem <sigmund@google.com>
> Commit-Queue: Riley Porter <rileyporter@google.com>

TBR=sigmund@google.com,srujzs@google.com,rileyporter@google.com

Change-Id: I6f4ff8f51f44d3e2eb1a140c93485ebe28189984
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/215160
Reviewed-by: Riley Porter <rileyporter@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-09-30 22:52:12 +00:00
Riley Porter 46486cf260 Add a generic return type for js_util functions
Allows further optimization to pass along return type
information and remove extra AsExpression casts.

Change-Id: I87aef171887e3f9af4c80003ff284eb2503d0cdb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214460
Reviewed-by: Srujan Gaddam <srujzs@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Commit-Queue: Riley Porter <rileyporter@google.com>
2021-09-30 17:13:49 +00:00
Riley Porter e559b80f52 Remove getProperty js_util optimization
Removing usage of the foreign JS function from the js_util
CFE optimizations. Keeps foreign JS calls only injected by
the compilers. There will be no change in generated JavaScript
for dart2js, it was already inlining getProperty calls. There
will be a small change for generated JavaScript for ddc, but
we will work on adding a simple ddc inliner to account for it.

Change-Id: Iadcc81a6798a8af397205bf6bb89d0bfbd095432
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/214306
Commit-Queue: Riley Porter <rileyporter@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Srujan Gaddam <srujzs@google.com>
2021-09-24 01:41:48 +00:00