From e3a4d6fa5607779a054c4062b6bab83d24a4f033 Mon Sep 17 00:00:00 2001 From: Sergej Jaskiewicz Date: Fri, 6 Jan 2023 14:31:45 +0100 Subject: [PATCH] Use star-projected types for building ScriptProvidedPropertyDescriptors Otherwise, the type parameters of the `kotlin.script.state` property of type `AggregatedReplStageState` were undefined, which led to building an ill-formed signature for the script class constructor. --- .../kotlin/scripting/resolve/LazyScriptDescriptor.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/resolve/LazyScriptDescriptor.kt b/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/resolve/LazyScriptDescriptor.kt index 1de07187e06..49717d2fa30 100644 --- a/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/resolve/LazyScriptDescriptor.kt +++ b/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/resolve/LazyScriptDescriptor.kt @@ -41,6 +41,7 @@ import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance import org.jetbrains.kotlin.types.typeUtil.isNothing import org.jetbrains.kotlin.types.typeUtil.isUnit +import org.jetbrains.kotlin.types.typeUtil.replaceArgumentsWithStarProjections import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import kotlin.reflect.KClass import kotlin.reflect.KType @@ -261,12 +262,14 @@ class LazyScriptDescriptor( private val scriptProvidedProperties: () -> List = resolveSession.storageManager.createLazyValue { scriptCompilationConfiguration()[ScriptCompilationConfiguration.providedProperties].orEmpty() .mapNotNull { (name, type) -> - findTypeDescriptor(getScriptingClass(type), Errors.MISSING_SCRIPT_PROVIDED_PROPERTY_CLASS) - ?.let { name.toValidJvmIdentifier() to it.defaultType.makeNullableAsSpecified(type.isNullable) } - }.map { (name, classDescriptor) -> + findTypeDescriptor(getScriptingClass(type), Errors.MISSING_SCRIPT_PROVIDED_PROPERTY_CLASS)?.let { + name.toValidJvmIdentifier() to + it.defaultType.makeNullableAsSpecified(type.isNullable).replaceArgumentsWithStarProjections() + } + }.map { (name, type) -> ScriptProvidedPropertyDescriptor( Name.identifier(name), - classDescriptor, + type, thisAsReceiverParameter, true, this