-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
There was a problem hiding this 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! ☀️
There was a problem hiding this 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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
31853ba
to
1d15a39
Compare
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 |
1d15a39
to
a070ef8
Compare
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`
a070ef8
to
5980f3e
Compare
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 |
rewritten as java.lang.Void in Scala.js IR
scala.runtime.BoxedUnit.TYPE value in one of its tests