Closed pomadchin closed 10 months ago
I wonder if package object X extends Serializable
makes a difference. Serializable
is a type alias in scala.package
object.
@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): https://github.com/locationtech/geotrellis/commit/b493b61430c51684ce4ff3f3bd1a00472e5992fe
This is the bell that rang https://github.com/scala/scala/pull/9661
miss the podcast ❤️ (the English-language one; I don't speak Russian)
👋 @SethTisue I miss it too ❤️
@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 (https://github.com/scala/scala/pull/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. 🤔
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.
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
Ha, yes, fails for me locally with scala-cli as well.
@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.
@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.
I've forgotten if all inheritance for package objects is deprecated?
@som-snytt Adriaan wanted that, but we ended up reverting it https://github.com/scala/scala-dev/issues/441
Thank-you both, I always forget which parallel universe we happen to find ourselves in.
~Wooot there is a fix already?~ I think I read it too fast.
Yes.
I may have coded it too fast.
@som-snytt woooot; incredible! I can try to test the PR later on all failing projects to double / triple check it.
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:
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
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 theCompile/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: https://github.com/PDAL/java/commit/f068ac26d59f893dce899dbe77e192f09d82400d CI Error: https://github.com/PDAL/java/actions/runs/4277401013/jobs/7446185708#step:6:201
Workarounds that work for now:
Ref to another project issue where I have the same problem https://github.com/locationtech/geotrellis/issues/3503