Scripting: Implement conditional conversion for REPL result values

to support value types erased from runtime classes. See example
in added tests for motivation.
#KT-45065 fixed
also refactor launcher repl test and result type rendering
This commit is contained in:
Ilya Chernikov
2022-05-16 16:53:37 +02:00
committed by teamcity
parent b36d1be5f8
commit 92bf260057
8 changed files with 127 additions and 49 deletions
@@ -23,6 +23,7 @@ import org.jetbrains.kotlin.ir.declarations.*
import org.jetbrains.kotlin.ir.declarations.impl.IrAnonymousInitializerImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrClassImpl
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
import org.jetbrains.kotlin.ir.descriptors.toIrBasedKotlinType
import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.expressions.impl.IrClassReferenceImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
@@ -290,7 +291,7 @@ private class ScriptsToClassesLowering(val context: JvmBackendContext, val inner
irScript.resultProperty?.owner?.let { irResultProperty ->
context.state.scriptSpecific.resultFieldName = irResultProperty.name.identifier
context.state.scriptSpecific.resultTypeString = irResultProperty.backingField?.type?.render()
context.state.scriptSpecific.resultType = irResultProperty.backingField?.type?.toIrBasedKotlinType()
}
}