mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-09 08:31:29 +00:00
- 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
18 lines
441 B
Kotlin
18 lines
441 B
Kotlin
import java.util.Arrays.equals
|
|
|
|
fun box(): String {
|
|
val s = array("live", "long")
|
|
val t = s.clone()
|
|
t : Array<String>
|
|
if (!equals(s, t)) return "Fail string"
|
|
if (s identityEquals t) return "Fail string identity"
|
|
|
|
val ss = array(s, s)
|
|
val tt = ss.clone()
|
|
tt : Array<Array<String>>
|
|
if (!equals(ss, tt)) return "Fail string[]"
|
|
if (ss identityEquals tt) return "Fail string[] identity"
|
|
|
|
return "OK"
|
|
}
|