Skip to content
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

Scala.js: Various JS interop fixes #9763

Closed
wants to merge 13 commits into from
Closed

Conversation

sjrd
Copy link
Member

@sjrd sjrd commented Sep 10, 2020

Depends on #9758 and #9725.

Normally, annotations applied to a class have no business being
replicated on a synthetic companion object. One exception was the
`@alpha` method, which is supposed to apply as well. Instead of
trying to identify those annotations without the symbols during
`Desugar`, we change `erasedName` to go look on the companion class
of synthetic module classes.
The `PrepJSInterop` phase is responsible for:

* Performing all kinds of Scala.js-specific compile-time checks,
  and emitting the appropriate compile errors.
* Perform some transformations that are necessary for JavaScript
  interop, notably generating exports forwarders.

This commit ports all the functionality of `PrepJSInterop` from
Scala 2, except the following:

* Handling of `scala.Enumeration`s: it is unclear whether we still
  want to support that in the core, or if it should be handled by
  an optional compiler plugin in the future.
* Exports: they will be done later.
* Warnings about duplicate fields in `js.Dynamic.literal`: mostly
  because they are non-essential.

The test cases are ported from the Scala.js compiler tests.
This is a forward port of the upstream commit
scala-js/scala-js@3c3b100

We now require the option
`-scalajs-genStaticForwardersForNonTopLevelObjects` to emit static
forwarders for non-top-level objects.

In addition, we take `-XnoForwarders` into account, which we were
erroneously not doing before.
This is a forward port of the upstream commit
scala-js/scala-js@6c82635

Since dotc does not support warning suppression yet, we use a
regular warning to report when we avoid emitting static forwarders.
And enable a number of tests that have been updated upstream to be
compatible with dotty.
This is a forward port of the back-end changes in the upstream
commit
scala-js/scala-js@a1a27f2
This is very important, as it prevents `SelectStatic` from creating
dangling references to global scope objects. Such dangling
references are invalid and trigger an error in the back-end.
Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Commit Messages

We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).

Please stick to these guidelines for commit messages:

  1. Separate subject from body with a blank line
  2. When fixing an issue, start your commit message with Fix #<ISSUE-NBR>:
  3. Limit the subject line to 72 characters
  4. Capitalize the subject line
  5. Do not end the subject line with a period
  6. Use the imperative mood in the subject line ("Add" instead of "Added")
  7. Wrap the body at 80 characters
  8. Use the body to explain what and why vs. how

adapted from https://chris.beams.io/posts/git-commit

Have an awesome day! ☀️

@sjrd
Copy link
Member Author

sjrd commented Sep 10, 2020

Oops. I created this PR from the wrong branch. This is superseded by #9767.

@sjrd sjrd closed this Sep 10, 2020
@sjrd sjrd deleted the sjs-value-classes branch September 10, 2020 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants