Alexander Sysoev
03/13/2026, 8:50 AMgpopides
03/13/2026, 1:31 PMinvoke method. Not sure if its expected though and intellij did not really helpAlexander Sysoev
03/13/2026, 1:32 PMgpopides
03/13/2026, 2:30 PMmessage Demo {
message Version {
string version = 1;
}
message Release {
string release_date = 1;
}
oneof request {
Version one = 1;
Release two = 2;
}
}
generates
interface Demo {
val request: Request?
sealed interface Request {
@JvmInline
value class One(val value: Version): Request
@JvmInline
value class Two(val value: Release): Request
}
@GeneratedProtoMessage
interface Version {
val version: String
}
@GeneratedProtoMessage
interface Release {
val releaseDate: String
}
}
which does not allow the following:
class DemoImpl: DemoService {
override suspend fun RunDemo(message: Demo): DemoResponse {
when (message.request) {
is Demo.Request.One -> {
message.request.value.version
}
is Demo.Request.Two -> {
message.request.value.releaseDate
}
else -> error("")
}
}
}
and we need a new variable for message.requestAlexander Sysoev
03/13/2026, 3:41 PMgpopides
03/13/2026, 3:46 PMAlexander Sysoev
03/13/2026, 3:54 PMorNull versions
So that you would get something like:
@GeneratedProtoMessage
interface MyMessage {
val some: String // optional in .proto
}
val myMessage: MyMessage
val a: String = myMessage.some // returns default value when absent
val b: String? = myMessage.someOrNull // returns null
myMessage.presence.hasSome()
Would you find this approach a good one?
This would also imply that in builders we would need to provide clear functions:
myMessage.copy {
some = "value" // OK
some = null // not possible by type mismatch
clearSome() // replacement for '= null'
}gpopides
03/13/2026, 4:18 PMAlexander Sysoev
03/13/2026, 4:22 PMAlexander Sysoev
03/13/2026, 4:24 PMUli Bubenheimer
03/13/2026, 4:44 PMAlexander Sysoev
03/13/2026, 4:47 PMmessage.field.nested1.nested2, no nulls), but add nullable options (fieldOrNull) for people who really like Kotlin's nullability handling (https://github.com/protocolbuffers/protobuf/issues/10178)Uli Bubenheimer
03/13/2026, 4:57 PM