Introduce kotlin.Cloneable
- Cloneable is a trait with a single protected member 'clone', which is mapped to java.lang.Cloneable on JVM - 'clone' is non-abstract to be able to call 'super.clone()' in the implementations. Also if you need your class to be Cloneable, most of the time inheriting from Cloneable and calling 'super.clone()' will work - hack 'super.clone()' in JVM intrinsics and TImpl delegation generation - make arrays Cloneable, handle 'clone()' calls in the intrinsic #KT-4890 Fixed
This commit is contained in:
@@ -26,13 +26,15 @@ class GenerateArrays(out: PrintWriter) : BuiltInsSourceGenerator(out) {
|
||||
override fun generateBody() {
|
||||
for (kind in PrimitiveType.values()) {
|
||||
val s = kind.capitalized
|
||||
out.println("public class ${s}Array(public val size: Int) {")
|
||||
out.println("public class ${s}Array(public val size: Int) : Cloneable {")
|
||||
out.println(" public fun get(index: Int): $s")
|
||||
out.println(" public fun set(index: Int, value: $s): Unit")
|
||||
out.println()
|
||||
out.println(" public fun iterator(): ${s}Iterator")
|
||||
out.println()
|
||||
out.println(" public val indices: IntRange")
|
||||
out.println()
|
||||
out.println(" public override fun clone(): ${s}Array")
|
||||
out.println("}")
|
||||
out.println()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user