score:9

Accepted answer

Scala thinks that the generic parameter for primitives is scala.<Primitive> e.g. scala.Int. It doesn't store the type in the Java class file, though arguably it could. (Or not; depends on whether there needs to be a distinction between Int and java.lang.Integer; under the hood the boxed form is java.lang.Integer, even if the compiler does a good job making you believe it is Int.)

Anyway, Scala has its own reflection capabilities which are in flux, but with 2.10 you can find the arguments of the Option types like so:

import scala.reflect.runtime.universe._
typeTag[Foo].tpe.members.collect{
  case m: MethodSymbol if m.isCaseAccessor => m 
}.foreach(m => println(m.name + " " + m.typeSignature))

and you'll get something like

quuux => scala.Option[java.lang.Integer]
quux => scala.Option[scala.Boolean]
qux => scala.Option[scala.Int]
baz => scala.Boolean
bar => scala.Int

Related Query

More Query from same tag