Skip to content

[Moshi 2] Null-safe adapter returned for non-nullable type #2066

@mpartel-oura

Description

@mpartel-oura

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions