For the upcoming "*Non-public primary constructor ...
# general-advice
s
For the upcoming "*Non-public primary constructor is exposed via the generated 'copy()' method of the 'data' class.*" change in the language, what do you think is going to be your go-to solution? I was thinking of providing a manual
copy()
function, only with the parameters that I need for each use case which will just create a new instance of the data class, just like the normal
copy
function would. Any reasons why I should not be doing that?
k
s
Ah that exists too, that's good to know! Although it does feel like this change is done for a good reason, and just slapping that on every such warning would not be the optimal approach for all cases, right?
I do see there that they do suggest the same: • Once all the illegal 'copy' method usages are migrated, please drop the ExposedCopyVisibility annotation. • You can introduce your own 'copy'-like method alongside the generated 'copy', and migrate all the usages to the introduced method. so a new
copy
function does sound like a reasonable solution for some cases at least