Skip to content

Bootstrapped pickling exception when pickling locally defined class. #2340

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
felixmulder opened this issue May 1, 2017 · 4 comments · Fixed by #11392
Closed

Bootstrapped pickling exception when pickling locally defined class. #2340

felixmulder opened this issue May 1, 2017 · 4 comments · Fixed by #11392

Comments

@felixmulder
Copy link
Contributor

felixmulder commented May 1, 2017

From ZipArchive.scala:

for (zipEntry <- iter) {
  val dir = getDir(dirs, zipEntry)
  if (!zipEntry.isDirectory) {
    class FileEntry() extends Entry(zipEntry.getName) {
      override def lastModified = zipEntry.getTime()
      override def input        = resourceInputStream(path)
      override def sizeOption   = None
    }
    val f = new FileEntry()
    dir.entries(f.name) = f
  }
}

Pickling fails when bootstrapping this as part of the killing reflect io PR.

Message:

java.lang.AssertionError: assertion failed: unresolved symbols: class FileEntry when pickling /Users/fixel/Projects/dotty/compiler/src/dotty/tools/io/ZipArchive.scala
	at scala.Predef$.assert(Predef.scala:170)
	at dotty.tools.dotc.core.tasty.TreePickler.pickle(TreePickler.scala:608)
	at dotty.tools.dotc.transform.Pickler$$anonfun$run$2$$anonfun$apply$1.apply(Pickler.scala:51)
	at dotty.tools.dotc.transform.Pickler$$anonfun$run$2$$anonfun$apply$1.apply(Pickler.scala:44)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.transform.Pickler$$anonfun$run$2.apply(Pickler.scala:44)
	at dotty.tools.dotc.transform.Pickler$$anonfun$run$2.apply(Pickler.scala:43)
	at scala.collection.immutable.List.foreach(List.scala:392)
	at dotty.tools.dotc.transform.Pickler.run(Pickler.scala:43)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:283)
	at dotty.tools.dotc.core.Phases$Phase$$anonfun$runOn$1.apply(Phases.scala:281)
	at scala.collection.immutable.List.map(List.scala:288)
	at dotty.tools.dotc.core.Phases$Phase$class.runOn(Phases.scala:281)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:75)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:76)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1$$anonfun$apply$mcV$sp$1.apply(Run.scala:73)
	at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply$mcV$sp(Run.scala:73)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.Run$$anonfun$compileUnits$1.apply(Run.scala:67)
	at dotty.tools.dotc.util.Stats$.monitorHeartBeat(Stats.scala:76)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:67)
	at dotty.tools.dotc.Run.compileSources(Run.scala:64)
	at dotty.tools.dotc.Run.compile(Run.scala:48)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:26)
	at dotty.tools.dotc.Driver.process(Driver.scala:124)
	at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:63)
	at xsbt.CachedCompilerImpl.run(CompilerInterface.scala:53)
	at xsbt.CompilerInterface.run(CompilerInterface.scala:37)
	at sun.reflect.GeneratedMethodAccessor22.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:107)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:53)
	at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:47)
	at sbt.compiler.MixedAnalyzingCompiler$$anonfun$compileScala$1$1.apply$mcV$sp(MixedAnalyzingCompiler.scala:50)
@odersky
Copy link
Contributor

odersky commented Jul 20, 2017

Can you make this into a self-contained test case? I tried to compile ZipArchive directly, but there were other incompatibilities which caused type errors.

smarter added a commit to dotty-staging/dotty that referenced this issue Jan 14, 2018
ZipArchive comes from scalac but was modified because the local class
failed to be pickled correctly previously. This appear to be fixed now,
so we can close scala#2340.
smarter added a commit to dotty-staging/dotty that referenced this issue Jan 14, 2018
ZipArchive comes from scalac but was modified because the local class
failed to be pickled correctly previously. This appear to be fixed now,
so we can close scala#2340.
@smarter
Copy link
Member

smarter commented Jan 14, 2018

Reproduction, alas not minimal: #3825

@allanrenucci
Copy link
Contributor

Not sure it is the same issue, but this fails -Ytest-pickler on master:

sealed class Entry(path: Int)

class Test {
  def test = {
    class FileEntry() extends Entry(1)
    val f = new FileEntry()
  }
}
> dotc Test.scala -Ytest-pickler -Ystop-after:pickler
exception occurred while compiling Test.scala
Exception in thread "main" class dotty.tools.dotc.reporting.diagnostic.messages$Error at ?: pickling difference for class Entry in Test.scala, for details:
                   |
                   |  diff before-pickling.txt after-pickling.txt
	at dotty.tools.dotc.reporting.Reporting.error(Reporter.scala:88)
	at dotty.tools.dotc.reporting.Reporting.error$(Reporter.scala:87)
	at dotty.tools.dotc.core.Contexts$Context.error(Contexts.scala:68)
	at dotty.tools.dotc.transform.Pickler.testSame(Pickler.scala:107)
	at dotty.tools.dotc.transform.Pickler.$anonfun$testUnpickler$6(Pickler.scala:99)
	at dotty.tools.dotc.transform.Pickler.$anonfun$testUnpickler$6$adapted(Pickler.scala:97)
	at scala.collection.TraversableLike$WithFilter.$anonfun$foreach$1(TraversableLike.scala:789)
	at scala.collection.mutable.HashMap.$anonfun$foreach$1(HashMap.scala:138)
	at scala.collection.mutable.HashTable.foreachEntry(HashTable.scala:236)
	at scala.collection.mutable.HashTable.foreachEntry$(HashTable.scala:229)
	at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
	at scala.collection.mutable.HashMap.foreach(HashMap.scala:138)
	at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:788)
	at dotty.tools.dotc.transform.Pickler.testUnpickler(Pickler.scala:97)
	at dotty.tools.dotc.transform.Pickler.runOn(Pickler.scala:83)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$3(Run.scala:125)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.trackTime(Stats.scala:47)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2(Run.scala:123)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$2$adapted(Run.scala:121)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
	at dotty.tools.dotc.Run.runPhases$1(Run.scala:121)
	at dotty.tools.dotc.Run.$anonfun$compileUnits$1(Run.scala:141)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
	at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:88)
	at dotty.tools.dotc.Run.compileUnits(Run.scala:107)
	at dotty.tools.dotc.Run.compileSources(Run.scala:94)
	at dotty.tools.dotc.Run.compile(Run.scala:78)
	at dotty.tools.dotc.Driver.doCompile(Driver.scala:29)
	at dotty.tools.dotc.Driver.process(Driver.scala:127)
	at dotty.tools.dotc.Driver.process(Driver.scala:96)
	at dotty.tools.dotc.Driver.process(Driver.scala:108)
	at dotty.tools.dotc.Driver.main(Driver.scala:135)
	at dotty.tools.dotc.Main.main(Main.scala)
java.lang.RuntimeException: Nonzero exit code returned from runner: 1
	at scala.sys.package$.error(package.scala:27)

The annotation @scala.annotation.internal.Child[FileEntry]() is missing after pickling

@nicolasstucki
Copy link
Contributor

@OlivierBlanvillain should have a look to that minimization. He has some experience and thoughts about sealed classes being extended by anonymous classes.

allanrenucci pushed a commit to allanrenucci/dotty that referenced this issue Jan 15, 2018
ZipArchive comes from scalac but was modified because the local class
failed to be pickled correctly previously. This appear to be fixed now,
so we can close scala#2340.
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Feb 12, 2021
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment