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 #20463

Merged
merged 1 commit into from
Jun 20, 2024

Conversation

jtjeferreira
Copy link
Contributor

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

@jtjeferreira
Copy link
Contributor Author

@jtjeferreira It seems the corresponding code in scala3 is GenericSignatures.scala

3.4.1/compiler/src/dotty/tools/dotc/transform/GenericSignatures.scala#L275

corresponds to

scala/scala#8127 (files)

Thanks for the pointer

@jtjeferreira
Copy link
Contributor Author

@lrytz I think I got the port applied correctly, but scalajs tests are failing with :

Test 'tests/run/i10846' failed with output:                                     
org.scalajs.linker.interface.LinkingException: There were linking errors

any hints?

@jtjeferreira
Copy link
Contributor Author

any hints?

after reading https://www.scala-js.org/doc/project/linking-errors.html#using-unsupported-jdk-libraries-possibly-transitively and earlier output of the tests I think the problem is due to the usage of java.lang.Class related method.

I think we need to disable this test for scalajs. Should I move it to a different folder?

@lrytz
Copy link
Member

lrytz commented Jun 4, 2024

It seems all tests in run will also be tested on Scala.js.

compileFilesInDir("tests/run", scalaJSOptions),

Someone else will know better than me where to put the test (eg @bishabosha).

@sjrd
Copy link
Member

sjrd commented Jun 4, 2024

You should keep it there. You can ignore a test on Scala.js like this:

// scalajs: --skip

@jtjeferreira jtjeferreira marked this pull request as ready for review June 4, 2024 16:58
@jtjeferreira
Copy link
Contributor Author

This is ready for review. Let me know if I should update the PR description and/or squash commits.

Also as discussed here, should this backported to LTS?

@jtjeferreira jtjeferreira changed the title WIP: Correct Java signature for value classes appearing in type arguments Correct Java signature for value classes appearing in type arguments Jun 17, 2024
@jtjeferreira
Copy link
Contributor Author

@lrytz @SethTisue this is ready for review

Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

LGTM, thank you! Could you squash all the changes into a single commit with a bit of a cleaned up commit message?

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

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

Thank you!

@lrytz lrytz merged commit 24efe7d into scala:main Jun 20, 2024
24 checks passed
@jtjeferreira
Copy link
Contributor Author

This will be available in which release? Shall I try to back port it to older releases?

@SethTisue
Copy link
Member

It will go in 3.6 and likely in some 3.3.x release unless the backport proves problematic. Backports are done in batches and in order of original merge, so it wouldn't actually be helpful to submit an explicit backport PR.

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.

Incorrect Java signature for value classes
5 participants