Skip to content

Code generation from proto definition fails using an empty message in proto #498

@sebaslogen

Description

@sebaslogen

Describe the bug
When using a message to define an object without any attribute (empty message), the generated kotlin code is broken for the toPlatform and toKotlin generated functions

To Reproduce
Steps to reproduce the behavior:

  1. Checkout the sample bug branch with modified proto file Add empty message to proto definition sebaslogen/kotlinx-rpc#1
  2. Navigate to samples/grpc-app
  3. Run ./gradlew bufGenerateMain to generate kotlin code
  4. Inspect the generated file samples/grpc-app/build/protoBuild/generated/main/kotlin-multiplatform/_rpc_internal/ImageRecognizer.kt

Actual outcome
Generated code (this code fails to compile):

fun DismissAction.toPlatform(): ImageRecognizerOuterClass.DismissAction {
    return ImageRecognizerOuterClass.DismissAction.newBuilder().apply
}

fun ImageRecognizerOuterClass.DismissAction.toKotlin(): DismissAction {
    return DismissAction
}

Expected behavior
Generated code compiles without errors
Example of how compiling code could look like:

fun DismissAction.toPlatform(): ImageRecognizerOuterClass.DismissAction {
    return ImageRecognizerOuterClass.DismissAction.newBuilder().build()
}

fun ImageRecognizerOuterClass.DismissAction.toKotlin(): DismissAction {
    return DismissAction {}
}

Additional context
Tested on version "0.10.0-grpc-121" of this library

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions