square / kotlinpoet

A Kotlin API for generating .kt source files.
https://square.github.io/kotlinpoet/
Apache License 2.0
3.88k stars 286 forks source link

Illegal syntax in enum class with only init block #1952

Closed brokenhappy closed 1 month ago

brokenhappy commented 1 month ago

Describe the bug Generating code for an enum builder that only has an init block is missing semicolon

To Reproduce

TypeSpec.enumBuilder("Foo")
      .addInitializerBlock(CodeBlock.EMPTY)
      .build()

Produces:

public enum class Foo {
  init {
  }
}

Expected behavior It should produce:

public enum class Foo {
  ;
  init {
  }
}