t

    thana

    3 years ago
    well.
    null
    is not supported with protobuf. that is a HUGE drawback
    s

    sandwwraith

    3 years ago
    Protobuf originally does not have concept of null, only presence and absence of value which is hard to map unambiguously on Kotlin's default values/default nullable values/nullable values without default/...
    t

    thana

    3 years ago
    yes found the bug report for this problem. i''l have a look what i can do 🙂
    is it only the nullable types with default values that cause the problems? or default values themselves?
    s

    sandwwraith

    3 years ago
    There are several problems there. What you should deserialize into
    val x: Int? = 42
    if
    x
    is missing? Even non-nullable
    val x: Int = 42
    can cause problems because protobuf specs clearly says that "absence of value should be treated as 0 for primitives and - huh - 'field is not set. Its exact value is language-dependent' for non-primitive types".
    Java's protobuf implementation uses
    null
    as 'not set', but we can't afford such luxury in Kotlin
    t

    thana

    3 years ago
    well i guess there are more problems here? at least those to seem to be easily solvable at first glane 🤔
    in the first case i'd guess if
    x
    is missing it was explicitly set to
    null
    in the second case the serialized form would simply missmatch
    what i couldn't fin out yet: is there anything i can do?