Skip to content

Partial fix for lampepfl#7113: Fix Scala.js codegen for BoxedUnit.TYPE #7415

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

Merged
merged 1 commit into from
Oct 23, 2019

Conversation

Lacaranian
Copy link
Contributor

  • Fix an issue where BoxedUnit's TYPE member was not being correctly
    rewritten as java.lang.Void in Scala.js IR
  • Enable the ClassTest for Scala.js, which uses the
    scala.runtime.BoxedUnit.TYPE value in one of its tests

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! ❤️

Have an awesome day! ☀️

Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

Thanks. The fix looks correct. I have two comments.

Also the commit message should say in its title what it fixes. The fact that it enables a test is secondary to that. I suggest:

Fix Scala.js codegen for BoxedUnit.TYPE.

It is now intercepted as a primitive for `ClassOf(ClassRef("V"))`,
i.e., `classOf[java.lang.Void]`.

Enable javalib/lang/ClassTest, which contains a test for this.

@@ -24,8 +24,9 @@ object JSPrimitives {
final val JS_NATIVE = TYPEOF + 1 // js.native. Marker method. Fails if tried to be emitted.

final val UNITVAL = JS_NATIVE + 1 // () value, which is undefined
final val UNITTYPE = UNITVAL + 1 // () type
Copy link
Member

Choose a reason for hiding this comment

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

This seems in fact unused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It seems so - probably doesn't need to be defined the way UNITVAL is. Removed.

@@ -2731,6 +2731,8 @@ class JSCodeGen()(implicit ctx: Context) {

if (sym == defn.BoxedUnit_UNIT) {
js.Undefined()
} else if(sym == defn.BoxedUnit_TYPE) {
Copy link
Member

Choose a reason for hiding this comment

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

Coding style nit: missing space after if.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@Lacaranian
Copy link
Contributor Author

Made fixes as per the review, and tuned the commit message accordingly. I'll improve the commit message on the similar lampepfl#7378 as well

@Lacaranian Lacaranian changed the title Issue lampepfl#7113: Enable javalib/lang/ClassTest for Scala.js Issue lampepfl#7113: Fix Scala.js codegen for BoxedUnit.TYPE Oct 21, 2019
@Lacaranian Lacaranian changed the title Issue lampepfl#7113: Fix Scala.js codegen for BoxedUnit.TYPE Partial fix for lampepfl#7113: Fix Scala.js codegen for BoxedUnit.TYPE Oct 22, 2019
@Lacaranian Lacaranian requested a review from sjrd October 22, 2019 14:06
@sjrd
Copy link
Member

sjrd commented Oct 22, 2019

Ah, this now needs to be rebased, after I merged #7439.

- `scala.runtime.BoxedUnit.TYPE` is now intercepted by `JSCodeGen` as a
  primitive for `ClassOf(ClassRef("V"))`, which Scala.js recognizes as
  `java.lang.Void`
- Enable the javalib/lang/ClassTest for Scala.js, which contains a test
  that uses `BoxedUnit.TYPE`
@Lacaranian
Copy link
Contributor Author

Rebased onto the latest - I wouldn't be surprised if #7378 runs into this too, though it may be able to do a fast forward rebase automatically if Build.scala conflicts again (and we're lucky).

@sjrd sjrd merged commit 5e503e2 into scala:master Oct 23, 2019
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.

3 participants