In master, Moshi.adapter<UserDefinedClass>() currently returns a null-safe adapter, meaning it behaves the same as Moshi.adapter<UserDefinedClass?>(). This test shows the problem. Adding println(generatedAdapter.fromJson("null")) to it indeed prints null, despite the type system thinking it can't.
I found this while trying to better understand where Moshi 2's nullability story is heading. Relatedly, I'm wondering, will nullability in nested types be supported before release?
In
master,Moshi.adapter<UserDefinedClass>()currently returns a null-safe adapter, meaning it behaves the same asMoshi.adapter<UserDefinedClass?>(). This test shows the problem. Addingprintln(generatedAdapter.fromJson("null"))to it indeed printsnull, despite the type system thinking it can't.I found this while trying to better understand where Moshi 2's nullability story is heading. Relatedly, I'm wondering, will nullability in nested types be supported before release?