class Foo[T]
object Test {
class Inner extends Foo[String]
def main(args: Array[String]): Unit = {
class Local extends Foo[String]
// Prints "Foo<java.lang.String>" as expected
println((new Inner).getClass.getGenericSuperclass)
// Prints "class Foo" instead of "Foo<java.lang.String>" because the generic
// signature for the parent is missing.
println((new Local).getClass.getGenericSuperclass)
}
}
In particular, this is needed to implement the "super type tokens" pattern described in http://gafter.blogspot.com/2006/12/super-type-tokens.html and used for example in http://fasterxml.github.io/jackson-core/javadoc/2.9/com/fasterxml/jackson/core/type/TypeReference.html
@smarter would this be a change that could be done for Scala 3 release? Without this, I'm not sure if jackson-module-scala can be made to work for Scala3. Of course, there are lots of other ways to work with JSON in scala and it could be about time to halt work on jackson-module-scala in favour of encouraging users onto alternatives.
No promise it'll be done for Scala 3.0.0, but I'll give it a try if I can find the time.
@smarter I'm no sure that this issue only affects local classes
val typeRef = new TypeReference[Map[String, String]]{}
This fails with same issue (java.lang.IllegalArgumentException: Internal error: TypeReference constructed without actual type information being thrown by TypeReference constructor)
new TypeReference[Map[String, String]]{} constructs an anonymous class, the anonymous class that is generated by the compiler is a local class.