Is it possible to tell Kotlin compiler to generate...
# announcements
d
Is it possible to tell Kotlin compiler to generate inner static classes out of object expressions?
d
Does it not do that? It does for me, also setting the enclosing class and enclosing method tags properly.
d
They are local which leads to an issue with jackson deserialization https://github.com/FasterXML/jackson-module-kotlin/issues/135
d
There is no object expression in the code posted there. There is a local class, hence
Class#isLocalClass
returns true. This is not Kotlin's "fault", the same would happen in Java.
d
when I do something like
Copy code
fun foo(bar: Sting): Any {
  val obj = object : SomeClass() {
    val buz = bar
  }
  return obj;
}
it becomes local too
d
Yes. Local means "inside a method".
d
So, I want the compiler to make it non-local
s
why not just move it out of the fun ?
d
But it is local... You want the compiler to generate wrong metadata...
d
Because this is less verbose when the object is defined in the method. And I don't have to invent a name for the class
At the same time, I need it to be json (de)serializable