Prohibit clone() for enum classes

#KT-8972 Fixed
This commit is contained in:
Alexander Udalov
2015-08-28 09:30:17 +03:00
parent 89f3cfc704
commit 29abf94327
6 changed files with 53 additions and 0 deletions
+6
View File
@@ -37,6 +37,12 @@ public abstract class Enum<E : Enum<E>>(name: String, ordinal: Int): Comparable<
public override final fun compareTo(other: E): Int
/**
* Throws an exception since enum constants cannot be cloned.
* This method prevents enum classes from inheriting from [Cloneable].
*/
protected final fun clone(): Any
public override final fun equals(other: Any?): Boolean
public override final fun hashCode(): Int
public override fun toString(): String