diff --git a/eval4j/src/org/jetbrains/eval4j/values.kt b/eval4j/src/org/jetbrains/eval4j/values.kt index 8ecef6767b9..eb12f09fb3c 100644 --- a/eval4j/src/org/jetbrains/eval4j/values.kt +++ b/eval4j/src/org/jetbrains/eval4j/values.kt @@ -81,9 +81,12 @@ class IntValue(value: Int, asmType: Type): AbstractValue(value, asmType) class LongValue(value: Long): AbstractValue(value, Type.LONG_TYPE) class FloatValue(value: Float): AbstractValue(value, Type.FLOAT_TYPE) class DoubleValue(value: Double): AbstractValue(value, Type.DOUBLE_TYPE) -public class ObjectValue(value: Any?, asmType: Type): AbstractValue(value, asmType) -class NewObjectValue(asmType: Type): AbstractValueBase(asmType) { +public open class ObjectValue(value: Any?, asmType: Type): AbstractValue(value, asmType) +class NewObjectValue(asmType: Type): ObjectValue(null, asmType) { override var value: Any? = null + get(): Any? { + return $value ?: throw IllegalStateException("Trying to access an unitialized object: $this") + } } class LabelValue(value: LabelNode): AbstractValue(value, Type.VOID_TYPE) @@ -106,11 +109,6 @@ val Value.long: Long get() = (this as LongValue).value val Value.float: Float get() = (this as FloatValue).value val Value.double: Double get() = (this as DoubleValue).value fun Value.obj(expectedType: Type = asmType): Any? { - if (this is NewObjectValue) { - val v = value - if (v == null) throw IllegalStateException("Trying to access an unitialized object: $this") - return v - } return when { expectedType == Type.BOOLEAN_TYPE -> this.boolean expectedType == Type.SHORT_TYPE -> (this as IntValue).int.toShort()