Supported recursive references in enums

Split enum entries initialization onto two steps:
1. Allocation of all instances and storing them in the array;
2. Calling constructors on each instance.
This commit is contained in:
Igor Chevdar
2017-11-29 18:49:21 +03:00
parent faa9986489
commit 6492682b28
4 changed files with 100 additions and 22 deletions
@@ -105,6 +105,16 @@ fun <T: Enum<T>> valuesForEnum(values: Array<T>): Array<T>
return result as Array<T>
}
@Intrinsic
internal fun <T> createUninitializedInstance(): T {
throw Exception("Call to this function should've been lowered")
}
@Intrinsic
internal fun initInstance(thiz: Any, constructorCall: Any): Unit {
throw Exception("Call to this function should've been lowered")
}
fun checkProgressionStep(step: Int) = if (step > 0) step else throw IllegalArgumentException("Step must be positive, was: $step.")
fun checkProgressionStep(step: Long) = if (step > 0) step else throw IllegalArgumentException("Step must be positive, was: $step.")