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

[Scala 3] Make instances Serializable #496

Closed
Tracked by #481
TimWSpence opened this issue Jun 6, 2022 · 1 comment
Closed
Tracked by #481

[Scala 3] Make instances Serializable #496

TimWSpence opened this issue Jun 6, 2022 · 1 comment

Comments

@TimWSpence
Copy link
Member

TimWSpence commented Jun 6, 2022

Currently failing in CI

Further investigation has revealed that it's actually a problem for all the derived instances. Example failure:

> Exception: java.io.NotSerializableException: cats.derived.ShowPrettySuite$$anon$3
    at munit.ScalaCheckSuite.propToTry(ScalaCheckSuite.scala:98)
Caused by: java.io.NotSerializableException: cats.derived.ShowPrettySuite$$anon$3

Decompiling that class:

javap core/.jvm/target/scala-3.1.2/test-classes/cats/derived/ShowPrettySuite\$\$anon\$3.class
Compiled from "ShowPrettySuite.scala"
final class cats.derived.ShowPrettySuite$$anon$3 implements scala.deriving.Mirror$Sum {
  public cats.derived.ShowPrettySuite$$anon$3();
  public int ordinal(cats.derived.TestDefns$IntTree);
  public int ordinal(java.lang.Object);
}

So the issue is that if a type doesn't have a companion object then the Mirror is derived as an anonymous class that is not Serializable.

The most obvious fix is to get Dotty to make these anonymous instances Serializable

@TimWSpence TimWSpence changed the title [Scala 3] Make ShowPretty instances Serializable [Scala 3] Make instances Serializable Jun 6, 2022
@TimWSpence
Copy link
Member Author

Tested locally against dotty 438dfb024faa91f4239f346fa4f496a20c5e3d15 (with the fix from scala/scala3#15391) and it resolves the issue 🎉

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

No branches or pull requests

1 participant