-
Notifications
You must be signed in to change notification settings - Fork 3.1k
SI-6710 / PR 5072 follow-up: fix Unit.box / Unit.unbox #5100
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
|
Hum ... why complicate the back-end when the user-space implementation of these methods was perfectly fine? Adding code in the compiler to avoid code in the library seems like entirely the wrong trade-off to me. |
|
This PR only fixes the regression of #5072. There's a lot more that could be done around this area: if you play a bit with Yet another question is whether we actually need to intercept the box/unbox methods and re-wire to the box/unbox implementations in |
yeah, it's just one way to do it, and it was more consistent. i had the same thought of course, see my other comment: i think we could just get rid of hijacking box/unbox altogether. |
|
it seems the logic was initially added to support the .net backend: 8e56e0e |
|
Or erasure could just generate calls to Another advantage of keeping the actual implem in |
115a862 to
46179eb
Compare
The backend replaces .box / .unbox methods by corresponding invocations to BoxesRunTime, but not for Unit. This commit restores the body of `Unit.box` and `Unit.unbox`.
|
I changed the patch: now it restores the implementations of Note that the implementation of Initially the method was just returning Longer-term, I think we should remove the re-wiring to BoxesRunTime and just put the implementations in the primitive companions. However, I think we need to implement the I think we should not deprecate |
|
LGTM |
| def f(a: Any) = "" + a | ||
| val n3 = f(null.asInstanceOf[Unit]) // "null", should be "()". probably same cause as SI-602. | ||
| assertThrows[AssertionError](assertEquals(n3, "()")) // should not throw | ||
| } |
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.
Sorry I didn't catch this before hand, but shouldn't this be a partest test, or a JUnit test which includes the code above as a String? This is a test of the compiler, not the library.
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.
right, i the entire test should be converted, i'll do that. note to slef: also do it for the inliner test (array.foreach)
The backend replaces .box / .unbox methods by corresponding invocations
to BoxesRunTime, but not for Unit.
This commit extends the backend to also intercept box/unbox on Unit.