scala / pickling

Fast, customizable, boilerplate-free pickling support for Scala
lampwww.epfl.ch/~hmiller/pickling
BSD 3-Clause "New" or "Revised" License
831 stars 79 forks source link

Cannot pickle scalameta Sources #264

Open MasseGuillaume opened 9 years ago

MasseGuillaume commented 9 years ago

I want to serialize scalameta trees

https://github.com/scalameta/example/blob/master/plugin/src/main/scala/org/scalameta/example/Example.scala#L12

import scala.pickling._
import scala.pickling.binary._
sources.pickle.value

I get a stackoverflow.

... at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:866) at scala.tools.nsc.typechecker.Contexts$Context.withOuter$1(Contexts.scala:845) at scala.tools.nsc.typechecker.Contexts$Context.implicitss(Contexts.scala:866) at scala.tools.nsc.typechecker.Contexts$Context.withOuter$1(Contexts.scala:845) ...

eed3si9n commented 9 years ago

I was not able able to get stack overflow using Pickling 0.10.0, but instead got OutOfMemory error.

steps

  lazy val pickling = "org.scala-lang.modules" %% "scala-pickling" % "0.10.0"
  lazy val plugin = Project(
    id   = "example",
    base = file("plugin"),
    settings = publishableSettings ++ mergeDependencies ++ Seq(
      libraryDependencies += compiler(languageVersion),
      libraryDependencies += scalameta,
      libraryDependencies += scalahost,
      libraryDependencies += pickling
    )
  )
package org.scalameta.example

import scala.meta.internal.ast._
import scala.meta.semantic._
import scala.meta.internal.hosts.scalac._

trait Example {
  val global: scala.tools.nsc.Global
  implicit val c = Scalahost.mkSemanticContext(global)

  def example(sources: List[Source]): Unit = {
    import scala.pickling._, Defaults._
    import scala.pickling.binary._
    println(sources.pickle.value)
  }
}

problem

Caused by: java.lang.OutOfMemoryError: Java heap space
    at scala.reflect.internal.util.WeakHashSet.resize(WeakHashSet.scala:124)
    at scala.reflect.internal.util.WeakHashSet.add$1(WeakHashSet.scala:180)
    at scala.reflect.internal.util.WeakHashSet.linkedListLoop$4(WeakHashSet.scala:185)
    at scala.reflect.internal.util.WeakHashSet.findEntryOrUpdate(WeakHashSet.scala:194)
    at scala.reflect.internal.Types$class.unique(Types.scala:3665)
    at scala.reflect.internal.SymbolTable.unique(SymbolTable.scala:16)
    at scala.reflect.internal.Types$ThisType$.apply(Types.scala:1191)
    at scala.reflect.internal.Symbols$ClassSymbol.thisType(Symbols.scala:3274)
    at scala.reflect.internal.Types$class.copyRefinedType(Types.scala:3443)
    at scala.reflect.internal.SymbolTable.copyRefinedType(SymbolTable.scala:16)
    at scala.reflect.internal.tpe.TypeMaps$TypeMap.mapOver(TypeMaps.scala:159)
    at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:716)
    at scala.reflect.internal.tpe.TypeMaps$TypeMap.mapOver(TypeMaps.scala:129)
    at scala.reflect.internal.tpe.TypeMaps$SubstMap.apply(TypeMaps.scala:716)
    at scala.reflect.internal.Types$Type.subst(Types.scala:705)
    at scala.reflect.internal.Types$Type.instantiateTypeParams(Types.scala:470)
    at scala.reflect.internal.Symbols$class.deriveTypeWithWildcards(Symbols.scala:3603)
    at scala.reflect.internal.SymbolTable.deriveTypeWithWildcards(SymbolTable.scala:16)
    at scala.tools.nsc.typechecker.Implicits$class.scala$tools$nsc$typechecker$Implicits$$depoly(Implicits.scala:154)
    at scala.tools.nsc.typechecker.Implicits$ImplicitSearch.scala$tools$nsc$typechecker$Implicits$ImplicitSearch$$matchesPt(Implicits.scala:484)
    at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation.survives(Implicits.scala:818)
    at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation$$anonfun$19$$anonfun$20.apply(Implicits.scala:872)
    at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation$$anonfun$19$$anonfun$20.apply(Implicits.scala:872)
    at scala.collection.TraversableLike$$anonfun$filterImpl$1.apply(TraversableLike.scala:259)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.TraversableLike$class.filterImpl(TraversableLike.scala:258)
    at scala.collection.TraversableLike$class.filter(TraversableLike.scala:270)
    at scala.collection.AbstractTraversable.filter(Traversable.scala:104)
    at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation$$anonfun$19.apply(Implicits.scala:872)
    at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation$$anonfun$19.apply(Implicits.scala:871)
    at scala.collection.immutable.List.flatMap(List.scala:327)
    at scala.tools.nsc.typechecker.Implicits$ImplicitSearch$ImplicitComputation.<init>(Implicits.scala:871)