Skip to content

[jsinterop] enforce additional restrictions on @staticInterop classes #49350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #49351
sigmundch opened this issue Jun 27, 2022 · 6 comments
Closed
Tracked by #49351
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop web-js-interop Issues that impact all js interop

Comments

@sigmundch
Copy link
Member

sigmundch commented Jun 27, 2022

We'd like to enforce some limitations to ensure the design of staticInterop classes matches static views (the future language feature that will be used to implement JSInterop in the future.) and supports the needs of JSinterop overall.

Some checks may include:

  • Type parameters are not allowed in extensions or extension methods themselves
  • Disallow generative constructors
  • Potentially disallow . delimiters in renaming for non-top level members if such a restriction does not exist already
@sigmundch sigmundch added web-js-interop Issues that impact all js interop area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop labels Jun 27, 2022
@srujzs
Copy link
Contributor

srujzs commented Jun 30, 2022

@jodinathan

Since js_bindings is one of the biggest users of this feature, do you see any of the above being major issues?

@jodinathan
Copy link

no @srujzs.

It seems I will only have to adjust to use external factory.

@srujzs
Copy link
Contributor

srujzs commented Jun 30, 2022

Great, thanks!

srujzs added a commit to srujzs/sqlite3.dart that referenced this issue Aug 15, 2022
dart-lang/sdk#49350 will disallow
generative constructors in @staticInterop classes in the near future.
simolus3 pushed a commit to simolus3/sqlite3.dart that referenced this issue Aug 15, 2022
dart-lang/sdk#49350 will disallow
generative constructors in @staticInterop classes in the near future.
@srujzs
Copy link
Contributor

srujzs commented Aug 17, 2022

@sigmundch Should we language version these checks? It might help avoid breaking users' code.

Also, I believe you've added this check:

Potentially disallow . delimiters in renaming for non-top level members if such a restriction does not exist already

but only for static members possibly? Do we see us needing to do this for instance/extension members as well?

copybara-service bot pushed a commit that referenced this issue Oct 18, 2022
Bug: #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 <[email protected]>
Commit-Queue: Srujan Gaddam <[email protected]>
Reviewed-by: Joshua Litt <[email protected]>
@srujzs
Copy link
Contributor

srujzs commented Oct 18, 2022

We no longer are requiring a single extension per @staticInterop class, so that error is removed. The other two have landed now that js_bindings is migrated.

@sigmundch
Copy link
Member Author

Per the last comment, I think we can close this issue as complete. That said, we are in the process of making the type-parameter check more lax, and allow certain generic patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-web-js Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

3 participants