xinthink / auto-data-class

Generator for Kotlin data classes with Gson/Parcelable type adapter
Apache License 2.0
15 stars 1 forks source link

Generated class is incorrect when data class has a read-only property with custom accessor #3

Open asaudemont opened 6 years ago

asaudemont commented 6 years ago

Sample class that illustrates the error:

@DataClass data class Foo(val x: Int) {
    var y: Int
        get() = x + 1
}

The generated class attempts to read a y property from the JSON object. It then instantiates Foo by including y in the constructor call, which is invalid and results in a compilation error.