[JS IR BE] Enum class lowering
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package kotlin
|
||||
|
||||
public class Enum<T : Enum<T>>(val name: String, val ordinal: Int) : Comparable<Enum<T>> {
|
||||
|
||||
override fun compareTo(other: Enum<T>) = ordinal.compareTo(other.ordinal)
|
||||
|
||||
override fun equals(other: Any?) = this === other
|
||||
|
||||
override fun hashCode(): Int = identityHashCode(this)
|
||||
|
||||
override fun toString() = name
|
||||
|
||||
companion object
|
||||
}
|
||||
@@ -102,3 +102,6 @@ fun hashCode(obj: dynamic): Int {
|
||||
"""
|
||||
).unsafeCast<Int>()
|
||||
}
|
||||
|
||||
// TODO: Use getObjectHashCode instead
|
||||
fun identityHashCode(obj: dynamic): Int = hashCode(obj)
|
||||
@@ -61,6 +61,9 @@ open class NoSuchElementException(message: String?, cause: Throwable?) : Runtime
|
||||
}
|
||||
|
||||
// TODO: fix function names to satisfy style convention (depends on built-in names)
|
||||
fun THROW_ISE() {
|
||||
throw IllegalStateException()
|
||||
}
|
||||
fun THROW_CCE() {
|
||||
throw ClassCastException()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user