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

Correct Java signature for value classes appearing in type arguments #8127

Merged
merged 1 commit into from
Jun 27, 2019

Conversation

hrhino
Copy link
Member

@hrhino hrhino commented Jun 6, 2019

Value class values are always boxed when used in a generic context.

Specifically, in

val foo: Option[VC] = Some(vc)

the runtime value of foo will be a Some wrapping a value of the (boxed) class VC. This is analogous to what happens with primitive value classes in this situation.

Renamed primitiveOK to imply that it affects the signature generated for any value class, not just primitives.

Fixes scala/bug#11321.

Value class values are always boxed when used in a generic context.
Specifically, in
    val foo: Option[VC] = Some(vc)
the runtime value of `foo` will be a `Some` wrapping a value of the
(boxed) class `VC`. This is analogous to what happens with primitive
value classes in this situation.

Renamed `primitiveOK` to imply that it affects the signature generated
for any value class, not just primitives.

Fixes scala/bug#11321.
@hrhino hrhino requested a review from retronym June 6, 2019 16:26
@scala-jenkins scala-jenkins added this to the 2.12.9 milestone Jun 6, 2019
dwijnand added a commit to dwijnand/mima that referenced this pull request Jun 13, 2019
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

This fixes a false negative in today's MiMa: lightbend-labs/mima#313.

👍 from me

@lrytz lrytz merged commit 17c0fe8 into scala:2.12.x Jun 27, 2019
@hrhino
Copy link
Member Author

hrhino commented Jun 27, 2019

Thanks!

@lrytz
Copy link
Member

lrytz commented Jun 27, 2019

Thank you!

@SethTisue SethTisue added the release-notes worth highlighting in next release notes label Jul 3, 2019
jtjeferreira added a commit to jtjeferreira/scala3 that referenced this pull request Jun 19, 2024
As suggested in scala#10846 the fix to this issue should be to port scala/scala#8127 to scala3
lrytz added a commit to scala/scala3 that referenced this pull request Jun 20, 2024
…20463)

As suggested in #10846 the fix to this issue should be to port
scala/scala#8127 to scala3

I started by adding the same tests as in the scala2 PR and then tried to
find the place where to do the fix by adding some log traces.
Unfortunately I am still pretty lost because this is my first time
looking at the compiler code.

Any tips where this needs to be fixed are very welcome. Meanwhile a few
questions:
* The scala2 fix was done in
`src/compiler/scala/tools/nsc/transform/Erasure.scala`, should I do the
fix for scala3 in
`compiler/src/dotty/tools/dotc/transform/Erasure.scala` as well?
* I think I need to do the fix around `ErasedValueType`, either when it
is created (in `TypeErasure#eraseDerivedValueClass`) or when it is used
(in `Erasure#unbox`).

Please also send me any pointers besides
https://dotty.epfl.ch/docs/contributing/index.html regarding compiler
contributions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-notes worth highlighting in next release notes
Projects
None yet
5 participants