ansman/kotshi

Generated factory type should be package scoped

Closed this issue · 4 comments

Hopefully this doesn't prevent consumers from other packages from seeing the JsonAdapter.Factory interface...

I think this will prevent the code from compiling on Kotlin, the subclass needs to have the same or tighter visibility.

Maybe you could do this instead?

@KotshiAdapterFactory
object MyFactory : JsonAdapter.Factory by KotshiMyFactory.INSTANCE

Ah, my usage is internal which is probably why it worked when I made the change.

I wonder if

@KotshiJsonAdapterFactory
object MyJsonAdapterFactory : JsonAdapter.Factory by KotshiMyJsonAdapterFactory

would work...

Biggest problem is that Kotlin won't recognize the Java as being an object so you'd be forced to do by KotshiMyJsonAdapterFactory.INSTANCE

Hah, yep. Downside of that approach, though, is that you get two instances instead of one. It's fine as-is.