Skip to content

not found: type Serializable after Scala 2.13.6 upgrade up to 2.13.7+ #12740

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

Closed
pomadchin opened this issue Feb 27, 2023 · 15 comments · Fixed by scala/scala#10333
Closed

not found: type Serializable after Scala 2.13.6 upgrade up to 2.13.7+ #12740

pomadchin opened this issue Feb 27, 2023 · 15 comments · Fixed by scala/scala#10333
Assignees
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) has PR
Milestone

Comments

@pomadchin
Copy link

pomadchin commented Feb 27, 2023

Reproduction steps

I was unable to get a locally reproducible / relatively easy project that fails. I could not reproduce it locally at all. 😭 Thx team with all the help to reproduce it!

Scala version: 2.13.7+
SBT and JDK versions independent.

Code:

package test

package object X extends Serializable { }

object Test {
  def main(args: Array[String]): Unit = {
    
  }

}

Scasite: https://scastie.scala-lang.org/pomadchin/X8YFi5YuT9yUNTp1fpmNEA/1

Publish: $ ./sbt +publishLocal

Steps to try to reproduce locally with the https://github.com/PDAL/java project

$ git clone git@github.com:PDAL/java.git pdal-java
$ git checkout -f bug/scala-upd
$ cd pdal-java
$ docker run --rm -it -v $PWD:/pdal daunnc/pdal-ubuntu:2.5.1 bash
$ cd /pdal
$ ./sbt ++2.13 core-scala/publishLocal

I know that it makes this bug / feature report very hard to work with, but mb there is any chance to get some help tracing it?
Any help / comments are really appreciated.

I spent a the whole weekend trying to catch it and was only able ("got lucky") to catch it in a smaller OSS project and reduce failure await times in CI.

Problem

In several projects (https://github.com/PDAL/java, https://github.com/locationtech/geotrellis/) after updating Scala 2.13.6 up to 2.13.7+ I get not found: type Serializable error on the package +publish command invocation, more specifically, on the Compile/doc stage.

The most unclear thing is that it may fail within some specific modules of a project, not in every module of a project, I was unable to catch the real issue / to find a simple reproducible way to catch it.

By experiments, I was able to double check that this behavior is not related to the SBT version and to the JDK version.

Code: https://github.com/PDAL/java/blob/bug/scala-upd/core-scala/src/main/scala/io/pdal/pipeline/package.scala#L19
Diff that triggers the CI error: PDAL/java@f068ac2
CI Error: https://github.com/PDAL/java/actions/runs/4277401013/jobs/7446185708#step:6:201

[error] /__w/java/java/core-scala/src/main/scala/io/pdal/pipeline/package.scala:19:75: not found: type Serializable
[error] package object pipeline extends json.Implicits with syntax.Implicits with Serializable
[error]                                                                           ^
[error] one error found
...
[error] Scaladoc generation failed
[error] 	at xsbt.Runner.run(ScaladocBridge.scala:50)
[error] 	at xsbt.ScaladocBridge.run(ScaladocBridge.scala:21)
[error] 	at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:154)
[error] 	at sbt.internal.inc.AnalyzingCompiler.doc(AnalyzingCompiler.scala:133)
[error] 	at sbt.Doc$.$anonfun$scaladoc$1(Doc.scala:52)
[error] 	at sbt.Doc$.$anonfun$scaladoc$1$adapted(Doc.scala:40)
[error] 	at sbt.RawCompileLike$.$anonfun$prepare$1(RawCompileLike.scala:79)
[error] 	at sbt.RawCompileLike$.$anonfun$prepare$1$adapted(RawCompileLike.scala:72)
[error] 	at sbt.RawCompileLike$.$anonfun$cached$4(RawCompileLike.scala:63)
[error] 	at sbt.RawCompileLike$.$anonfun$cached$4$adapted(RawCompileLike.scala:61)
[error] 	at sbt.util.Tracked$.$anonfun$inputChangedW$1(Tracked.scala:219)
[error] 	at sbt.RawCompileLike$.$anonfun$cached$1(RawCompileLike.scala:68)
[error] 	at sbt.RawCompileLike$.$anonfun$cached$1$adapted(RawCompileLike.scala:52)
[error] 	at sbt.Defaults$.$anonfun$docTaskSettings$4(Defaults.scala:2156)
[error] 	at scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] 	at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62)
[error] 	at sbt.std.Transform$$anon$4.work(Transform.scala:68)
[error] 	at sbt.Execute.$anonfun$submit$2(Execute.scala:282)
[error] 	at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] 	at sbt.Execute.work(Execute.scala:[291])
[error] 	at sbt.Execute.$anonfun$submit$1(Execute.scala:282)
[error] 	at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] 	at sbt.CompletionService$$anon$2.call(CompletionService.scala:64)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[error] 	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[error] 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[error] 	at java.base/java.lang.Thread.run(Thread.java:829)
[error] (core-scala / Compile / doc) Scaladoc generation failed

Workarounds that work for now:

  • Skipping the doc stage
  • Using java.io.Serializable instead of scala.Serializable in places that cause problems
  • Use Scala 2.13.6

Ref to another project issue where I have the same problem locationtech/geotrellis#3503

@som-snytt
Copy link

I wonder if package object X extends Serializable makes a difference. Serializable is a type alias in scala.package object.

@pomadchin
Copy link
Author

pomadchin commented Feb 27, 2023

@som-snytt wow a nice guess, it could be it, I can check it really quick.

However in some cases it could be caused by a trait, i.e. check this out (another project where I noticed the same behavior): locationtech/geotrellis@b493b61

@som-snytt
Copy link

This is the bell that rang scala/scala#9661

@SethTisue
Copy link
Member

miss the podcast ❤️ (the English-language one; I don't speak Russian)

@pomadchin
Copy link
Author

👋 @SethTisue I miss it too ❤️

@pomadchin
Copy link
Author

pomadchin commented Feb 27, 2023

@som-snytt apparently it turned out to be not that easy to check 🤦 I added classes and they are not failing; only the only one causes failure (link to a diff to get error back).

But I think it is a very nice guess (scala/scala#9661), it could be smth related to the loading ordering. That may explain why in some projects / modules package objects are compiling fine and in some are not, and why it's so hard to reproduce. 🤔

@pomadchin
Copy link
Author

I was able to reproduce it in Scastie (https://scastie.scala-lang.org/pomadchin/X8YFi5YuT9yUNTp1fpmNEA/1), sadly still not locally; seems to be the fact that is a package object affects it indeed.

@SethTisue SethTisue added the fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) label Feb 27, 2023
@SethTisue
Copy link
Member

SethTisue commented Feb 27, 2023

it reproduces for me locally with scala-cli and

//> using scala "2.13.10"                                                                           
package test
package object X extends Serializable { }                                                           
object Test {
  def main(args: Array[String]): Unit = {
  }
}

this fails during normal compilation, not even Scaladoc generation

@pomadchin
Copy link
Author

pomadchin commented Feb 27, 2023

Ha, yes, fails for me locally with scala-cli as well.

@som-snytt
Copy link

@SethTisue nice minimal rendition

@pomadchin I've forgotten if all inheritance for package objects is deprecated? Not to blame the victim. It may explain why it's not been reported. I fixed -Yimports for package objects, another underutilized feature.

@pomadchin
Copy link
Author

pomadchin commented Feb 27, 2023

@som-snytt I think package objects are deprecated and to be removed in general, since the top level expressions are legit in Scala 3.

Wooot there is a fix already? I think I read it too fast.

@SethTisue
Copy link
Member

I've forgotten if all inheritance for package objects is deprecated?

@som-snytt Adriaan wanted that, but we ended up reverting it scala/scala-dev#441

@som-snytt
Copy link

Thank-you both, I always forget which parallel universe we happen to find ourselves in.

@som-snytt
Copy link

Wooot there is a fix already? I think I read it too fast.

Yes.

I may have coded it too fast.

@pomadchin
Copy link
Author

@som-snytt woooot; incredible! I can try to test the PR later on all failing projects to double / triple check it.

@SethTisue SethTisue modified the milestones: 2.13.11, 2.13.12 Mar 28, 2023
@SethTisue SethTisue modified the milestones: 2.13.12, 2.13.13 Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixed in Scala 3 This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/) has PR
Projects
None yet
3 participants