Drop Cloneable in JS, synthesize it at compile-time on JVM
Use the same approach that is used for creating function type classes
(Function{0,1,...}) + add Cloneable to supertypes of Array and primitive arrays
#KT-5537 Fixed
This commit is contained in:
@@ -23,7 +23,7 @@ package kotlin
|
||||
* See [Kotlin language documentation](http://kotlinlang.org/docs/reference/basic-types.html#arrays)
|
||||
* for more information on arrays.
|
||||
*/
|
||||
public class Array<T> : Cloneable {
|
||||
public class Array<T> {
|
||||
/**
|
||||
* Creates a new array with the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -57,9 +57,4 @@ public class Array<T> : Cloneable {
|
||||
* Creates an iterator for iterating over the elements of the array.
|
||||
*/
|
||||
public operator fun iterator(): Iterator<T>
|
||||
|
||||
/**
|
||||
* Creates a shallow copy of the array.
|
||||
*/
|
||||
public override fun clone(): Array<T>
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ package kotlin
|
||||
* An array of bytes. When targeting the JVM, instances of this class are represented as `byte[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
|
||||
*/
|
||||
public class ByteArray(size: Int) : Cloneable {
|
||||
public class ByteArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -39,15 +39,13 @@ public class ByteArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): ByteIterator
|
||||
|
||||
public override fun clone(): ByteArray
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of chars. When targeting the JVM, instances of this class are represented as `char[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
|
||||
*/
|
||||
public class CharArray(size: Int) : Cloneable {
|
||||
public class CharArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -64,15 +62,13 @@ public class CharArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): CharIterator
|
||||
|
||||
public override fun clone(): CharArray
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of shorts. When targeting the JVM, instances of this class are represented as `short[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
|
||||
*/
|
||||
public class ShortArray(size: Int) : Cloneable {
|
||||
public class ShortArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -89,15 +85,13 @@ public class ShortArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): ShortIterator
|
||||
|
||||
public override fun clone(): ShortArray
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of ints. When targeting the JVM, instances of this class are represented as `int[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
|
||||
*/
|
||||
public class IntArray(size: Int) : Cloneable {
|
||||
public class IntArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -114,15 +108,13 @@ public class IntArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): IntIterator
|
||||
|
||||
public override fun clone(): IntArray
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of longs. When targeting the JVM, instances of this class are represented as `long[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
|
||||
*/
|
||||
public class LongArray(size: Int) : Cloneable {
|
||||
public class LongArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -139,15 +131,13 @@ public class LongArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): LongIterator
|
||||
|
||||
public override fun clone(): LongArray
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of floats. When targeting the JVM, instances of this class are represented as `float[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
|
||||
*/
|
||||
public class FloatArray(size: Int) : Cloneable {
|
||||
public class FloatArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -164,15 +154,13 @@ public class FloatArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): FloatIterator
|
||||
|
||||
public override fun clone(): FloatArray
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of doubles. When targeting the JVM, instances of this class are represented as `double[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to zero.
|
||||
*/
|
||||
public class DoubleArray(size: Int) : Cloneable {
|
||||
public class DoubleArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -189,15 +177,13 @@ public class DoubleArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): DoubleIterator
|
||||
|
||||
public override fun clone(): DoubleArray
|
||||
}
|
||||
|
||||
/**
|
||||
* An array of booleans. When targeting the JVM, instances of this class are represented as `boolean[]`.
|
||||
* @constructor Creates a new array of the specified [size], with all elements initialized to false.
|
||||
*/
|
||||
public class BooleanArray(size: Int) : Cloneable {
|
||||
public class BooleanArray(size: Int) {
|
||||
/**
|
||||
* Creates a new array of the specified [size], where each element is calculated by calling the specified
|
||||
* [init] function. The [init] function returns an array element given its index.
|
||||
@@ -214,7 +200,5 @@ public class BooleanArray(size: Int) : Cloneable {
|
||||
|
||||
/** Creates an iterator over the elements of the array. */
|
||||
public operator fun iterator(): BooleanIterator
|
||||
|
||||
public override fun clone(): BooleanArray
|
||||
}
|
||||
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
* Classes that inherit from this interface support creating field-by-field copies of their instances.
|
||||
*/
|
||||
public interface Cloneable {
|
||||
/**
|
||||
* Creates and returns a field-by-field copy of this object.
|
||||
*/
|
||||
protected fun clone(): Any { /* intrinsic */ }
|
||||
}
|
||||
Reference in New Issue
Block a user