Skip to content

Generated Kotlin codes for optional fields in proto3 is Kotlin not-nullable fields, and they're better to be nullable fields. #745

@chuanwise

Description

@chuanwise

To read the optional field foo in Kotlin:

optional int64 foo = 1;

Because the generated codes are like:

@java.lang.Override
public boolean hasFoo() { ... }

@java.lang.Override
public long getFoo() { ... }

We need to bar.foo.takeIf { bar.hasFoo() }, which is not Kotlin-friendly. It's expected to add @Nullable or @NotNull to getter methods.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions