vert-x3 / vertx-lang-kotlin

Vert.x for Kotlin
Apache License 2.0
296 stars 68 forks source link

[Codegen] Compilation error for DataObjects with "is" prefix for Booleans #158

Closed rgmz closed 1 year ago

rgmz commented 4 years ago

Consider the following DataObject:

@DataObject(generateConverter = true)
class Account() {
  var isActive: Boolean? = null

  constructor(json: JsonObject) : this() {
    AccountConverter.fromJson(json, this)
  }
}

When the converter is generated it will incorrectly reference active instead of isActive:

fun accountOf(
  active: Boolean? = null): Account = io.vertx.example.Account().apply {

  if (active != null) {
    this.active = active
  }
}

...resulting in a compilation error:

> Task :compileKotlin FAILED
e: .../project/build/generated/source/kaptKotlin/main/io/vertx/example/Account.kt: (24, 10): Unresolved reference: active
e: .../project/build/generated/source/kaptKotlin/main/io/vertx/example/Account.kt: (36, 10): Unresolved reference: active

FAILURE: Build failed with an exception.

This seems to be due to the fact that isActive: Boolean translates into GET:isActive() and SET:setActive(), e.g. https://github.com/sockeqwe/fragmentargs/issues/46