Private setter for var in primary constructor

Maybe instead of having an option for a custom getter/setter in the primary constructor it could be possible to annotate properties so they are treated as if they are part of the primary constructor. Something like this

data class Foo(id: Int, val name: String) {
    
    @Data
    val id: Int = id
}

In that case data classes would also need to allow parameters which are not directly defined as a property, but I don’t see any good reason why this must be the case.

2 Likes