Skip to content

Bug Fix getting Class Info from a class with a field from another class' inner class. #9

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

nbauernfeind
Copy link

I'm using jackson-module-scala which uses scalabeans under the covers. I want to serialize a class that looks like this:

class Metrics {
  outer =>
  val numThingA = new Counter(...)
  val numThingB  = new Counter(...)
  val currThingC = new AtomicReference(...)
  // ... etc you get the point

  def newSnapshot = new Snapshot  
  case class Snapshot (
    numThingA: Long = outer.numThingA.count,
    numThingB: Long = outer.numThingB.count,
    currThingC: C = outer.currThingC.get
  )
}

In the end I stick the snapshot into a case class:

case class DataResponse(..., metrics: Metrics#Snapshot)

But it fails to serialize the snapshot with this exception:

scala.MatchError: org.scalastuff.scalabeans.sig.OuterTestClass (of class org.scalastuff.scalabeans.sig.ClassDeclExtractor$$anonfun$13$$anon$10)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler.getTypeDecl$1(ScalaTypeCompiler.scala:155)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler.resolveScalaType(ScalaTypeCompiler.scala:167)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler$$anonfun$3.apply(ScalaTypeCompiler.scala:146)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler$$anonfun$3.apply(ScalaTypeCompiler.scala:145)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
    at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:233)
    at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:60)
    at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
    at scala.collection.TraversableLike$class.map(TraversableLike.scala:233)
    at scala.collection.mutable.ArrayBuffer.map(ArrayBuffer.scala:47)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler.compile(ScalaTypeCompiler.scala:145)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler$$anonfun$1$$anonfun$apply$2.apply(ScalaTypeCompiler.scala:51)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler$$anonfun$1$$anonfun$apply$2.apply(ScalaTypeCompiler.scala:48)
    at scala.Option$WithFilter.map(Option.scala:174)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler$$anonfun$1.apply(ScalaTypeCompiler.scala:48)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler$$anonfun$1.apply(ScalaTypeCompiler.scala:47)
    at scala.Option.flatMap(Option.scala:146)
    at org.scalastuff.scalabeans.sig.ScalaTypeCompiler$.classInfoOf(ScalaTypeCompiler.scala:47)
...

So, here's a fix... and it works. Test fails beforehand but required the helper classes to be at the top level.

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

Successfully merging this pull request may close these issues.

1 participant