Is there a binary-compatible way to turn an `objec...
# getting-started
y
Is there a binary-compatible way to turn an
object
into an
open class
that has a companion that implements it?
This seems to work fine:
Copy code
public abstract class Foo {
  public companion object: Foo() {
    @JvmField
    public val INSTANCE: Foo = this
  }
}
🤯 1
k
It's not 100% the same though: if existing Java code looked at
Foo.INSTANCE.getClass()
they would get
Foo.class
with the original code, but after the change it would be
Foo.Companion.class
.
y
Sure, but I don't think that's a breaking change really since it's reflect-y. I see what you mean though.
e
it is a binary breaking change, the type of the field is baked into the retrieval
also every call to any members