-
Notifications
You must be signed in to change notification settings - Fork 21
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
Map's second parameter is Object on reflection for primitive types #4403
Comments
Imported From: https://issues.scala-lang.org/browse/SI-4403?orig=1 |
@paulp said: You can (and will have to) get the information out of the scala signature. Clearly our motivation to make this easy with a scala reflection library has gone way up recently, but it's not imminent. There is code out there somewhere to dredge the info out, and/or you can look at scalap. |
@retronym said: scala> class Derper(m: Map[String, Long])
defined class Derper
scala> val tpe = reflect.mirror.classToType(classOf[Derper])
tpe: reflect.mirror.Type = Derper
scala> val c = tpe.member(reflect.mirror.nme.CONSTRUCTOR)
c: reflect.mirror.Symbol = constructor Derper
scala> val reflect.mirror.MethodType(Seq(param0), _) = c.asType
warning: there were 1 unchecked warnings; re-run with -unchecked for details
param0: reflect.mirror.Symbol = value m
scala> val typeArgs = param0.asType.typeArguments
typeArgs: List[reflect.mirror.Type] = List(String, Long)
scala> typeArgs.last.typeSymbol.fullName
res25: String = scala.Long So given the replacement, and Paul's explanation of why Java reflection can never again see the full details, let's close as not-a-bug. |
So there I was, trying to reflect on constructor parameters in Scala 2.9.0.RC1.
=== What is the expected behavior? ===
In Scala 2.8.1, the output is this:
This is awesome, since I have the information I need.
=== What do you see instead? ===
In Scala 2.9.0.RC1, this happens instead:
scala.collection.immutable.Map<java.lang.String, java.lang.Object>
scala.collection.immutable.Map<java.lang.String, com.yammer.streamie.Derper>
sad trombone noise
Now I have no idea what the values of the map should be.
This is really important for me, since I'm the author of Jerkson, a thin Scala layer on top of Jackson. I use reflection to deserialize case classes from JSON objects, but if one of the values of a case class is a Map, I don't have enough information to deserialize it in 2.9.0.RC1.
=== What versions of the following are you using? ===
The text was updated successfully, but these errors were encountered: