Kotlin Script - Passing generic types via providedProperties / implicitReceivers

Hello, I’ve been trying to pass some generic types (such as kotlinx.html.TagConsumer<String> or kotlin.collections.Map<String, Any?>), but I found it not working properly.
When I decompiled the .class file generated by kotlin.script.experimental.jvmhost.BasicJvmScriptClassFilesGenerator, its type was displayed as kotlinx.html.TagConsumer<[ERROR : Unknown type parameter 0. Please try recompiling module containing "[container not found]"]>.
I’ve looked into the actual code of the kotlin scripting api, and found that the class kotlin.script.experimental.api.KotlinType (which is the type that providedProperties and implicitReceivers of ScriptCompilationConfiguration requires) would change a KType instance to a KClass classifier (which would erase type parameters) and then build a KotlinType of it.
Is there any other way to pass generic typed values to a kotlin script?

I encountered the same problem.

Providing a generic type in providedProperties does not seem to work:

ScriptCompilationConfiguration:

providedProperties(
  "test1" to
    Map::class.createType(
      arguments =
        listOf(
          KTypeProjection.invariant(String::class.createType()),
          KTypeProjection.invariant(String::class.createType())
        )
    )
)

ScriptEvaluationConfiguration:
providedProperties("test1" to mapOf("test2" to "output"))

Script:
test1["test2"]

I am getting
[ERROR] Type inference failed. The value of the type parameter K should be mentioned in input types (argument types, receiver type or expected type). Try to specify it explicitly.