Definitely seems to be an error.
There are 2 problems with that code that you found:
- The need to specify type parameter on Comparable (note you do not need to add the “in”)
- Java’s clone is protected
The code was revised in the current version to make the result List which adds another error:
- If you were to be able to clone you would then need to cast to T which is not a problem in your example since you have List
I think the point of the example was about multiple where clauses not about cloning, but the code in the reference should be correct.
The cloneable issue was discussed here, but did not solve the problem:
Apparentlhy clone is not supported in Kotlin?