Add fix for interpretation const val
After FIR2IR processing getter doesn't has body, but has initializer. On the other hand common IR has body for const val getter
This commit is contained in:
+8
-1
@@ -307,7 +307,8 @@ class IrInterpreter(irModule: IrModuleFragment, private val bodyMap: Map<IdSigna
|
||||
dispatchReceiver is Wrapper && !isInlineOnly -> dispatchReceiver.getMethod(irFunction).invokeMethod(irFunction)
|
||||
irFunction.hasAnnotation(evaluateIntrinsicAnnotation) -> Wrapper.getStaticMethod(irFunction).invokeMethod(irFunction)
|
||||
dispatchReceiver is Primitive<*> -> calculateBuiltIns(irFunction) // 'is Primitive' check for js char and js long
|
||||
irFunction.body == null -> irFunction.trySubstituteFunctionBody() ?: calculateBuiltIns(irFunction)
|
||||
irFunction.body == null ->
|
||||
irFunction.trySubstituteFunctionBody() ?: irFunction.tryCalculateLazyConst() ?: calculateBuiltIns(irFunction)
|
||||
else -> irFunction.interpret()
|
||||
}
|
||||
}.check { return it }.implicitCastIfNeeded(expression.type, irFunction.returnType, stack)
|
||||
@@ -327,6 +328,12 @@ class IrInterpreter(irModule: IrModuleFragment, private val bodyMap: Map<IdSigna
|
||||
}
|
||||
}
|
||||
|
||||
// TODO fix in FIR2IR; const val getter must have body with IrGetField node
|
||||
private suspend fun IrFunction.tryCalculateLazyConst(): ExecutionResult? {
|
||||
if (this !is IrSimpleFunction) return null
|
||||
return this.correspondingPropertySymbol?.owner?.backingField?.initializer?.interpret()
|
||||
}
|
||||
|
||||
private suspend fun interpretInstanceInitializerCall(call: IrInstanceInitializerCall): ExecutionResult {
|
||||
val irClass = call.classSymbol.owner
|
||||
|
||||
|
||||
Reference in New Issue
Block a user