Refactor scripting - get rid of unused type parameter in CompiledScript
This commit is contained in:
+3
-3
@@ -22,7 +22,7 @@ import kotlin.script.experimental.jvm.jvm
|
||||
open class CompiledScriptJarsCache(val scriptToFile: (SourceCode, ScriptCompilationConfiguration) -> File?) :
|
||||
CompiledJvmScriptsCache {
|
||||
|
||||
override fun get(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration): CompiledScript<*>? {
|
||||
override fun get(script: SourceCode, scriptCompilationConfiguration: ScriptCompilationConfiguration): CompiledScript? {
|
||||
val file = scriptToFile(script, scriptCompilationConfiguration)
|
||||
?: throw IllegalArgumentException("Unable to find a mapping to a file for the script $script")
|
||||
|
||||
@@ -42,14 +42,14 @@ open class CompiledScriptJarsCache(val scriptToFile: (SourceCode, ScriptCompilat
|
||||
}
|
||||
|
||||
override fun store(
|
||||
compiledScript: CompiledScript<*>,
|
||||
compiledScript: CompiledScript,
|
||||
script: SourceCode,
|
||||
scriptCompilationConfiguration: ScriptCompilationConfiguration
|
||||
) {
|
||||
val file = scriptToFile(script, scriptCompilationConfiguration)
|
||||
?: throw IllegalArgumentException("Unable to find a mapping to a file for the script $script")
|
||||
|
||||
val jvmScript = (compiledScript as? KJvmCompiledScript<*>)
|
||||
val jvmScript = (compiledScript as? KJvmCompiledScript)
|
||||
?: throw IllegalArgumentException("Unsupported script type ${compiledScript::class.java.name}")
|
||||
|
||||
jvmScript.saveToJar(file)
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ open class JvmScriptCompiler(
|
||||
override suspend operator fun invoke(
|
||||
script: SourceCode,
|
||||
scriptCompilationConfiguration: ScriptCompilationConfiguration
|
||||
): ResultWithDiagnostics<CompiledScript<*>> =
|
||||
): ResultWithDiagnostics<CompiledScript> =
|
||||
compilerProxy.compile(
|
||||
script,
|
||||
scriptCompilationConfiguration.with {
|
||||
|
||||
+5
-5
@@ -22,11 +22,11 @@ import kotlin.script.experimental.jvm.util.scriptCompilationClasspathFromContext
|
||||
open class BasicJvmScriptClassFilesGenerator(val outputDir: File) : ScriptEvaluator {
|
||||
|
||||
override suspend operator fun invoke(
|
||||
compiledScript: CompiledScript<*>,
|
||||
compiledScript: CompiledScript,
|
||||
scriptEvaluationConfiguration: ScriptEvaluationConfiguration
|
||||
): ResultWithDiagnostics<EvaluationResult> {
|
||||
try {
|
||||
if (compiledScript !is KJvmCompiledScript<*>)
|
||||
if (compiledScript !is KJvmCompiledScript)
|
||||
return failure("Cannot generate classes: unsupported compiled script type $compiledScript")
|
||||
val module = (compiledScript.compiledModule as? KJvmCompiledModuleInMemory)
|
||||
?: return failure("Cannot generate classes: unsupported module type ${compiledScript.compiledModule}")
|
||||
@@ -47,7 +47,7 @@ open class BasicJvmScriptClassFilesGenerator(val outputDir: File) : ScriptEvalua
|
||||
}
|
||||
}
|
||||
|
||||
fun KJvmCompiledScript<*>.saveToJar(outputJar: File) {
|
||||
fun KJvmCompiledScript.saveToJar(outputJar: File) {
|
||||
val module = (compiledModule as? KJvmCompiledModuleInMemory)
|
||||
?: throw IllegalArgumentException("Unsupported module type $compiledModule")
|
||||
val dependenciesFromScript = compilationConfiguration[ScriptCompilationConfiguration.dependencies]
|
||||
@@ -90,11 +90,11 @@ fun KJvmCompiledScript<*>.saveToJar(outputJar: File) {
|
||||
open class BasicJvmScriptJarGenerator(val outputJar: File) : ScriptEvaluator {
|
||||
|
||||
override suspend operator fun invoke(
|
||||
compiledScript: CompiledScript<*>,
|
||||
compiledScript: CompiledScript,
|
||||
scriptEvaluationConfiguration: ScriptEvaluationConfiguration
|
||||
): ResultWithDiagnostics<EvaluationResult> {
|
||||
try {
|
||||
if (compiledScript !is KJvmCompiledScript<*>)
|
||||
if (compiledScript !is KJvmCompiledScript)
|
||||
return failure("Cannot generate jar: unsupported compiled script type $compiledScript")
|
||||
compiledScript.saveToJar(outputJar)
|
||||
return ResultWithDiagnostics.Success(EvaluationResult(ResultValue.NotEvaluated, scriptEvaluationConfiguration))
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class JvmReplEvaluator(
|
||||
): ReplEvalResult = state.lock.write {
|
||||
val evalState = state.asState(JvmReplEvaluatorState::class.java)
|
||||
val history = evalState.history as ReplStageHistoryWithReplace
|
||||
val compiledScript = (compileResult.data as? KJvmCompiledScript<*>)
|
||||
val compiledScript = (compileResult.data as? KJvmCompiledScript)
|
||||
?: return ReplEvalResult.Error.CompileTime("Unable to access compiled script: ${compileResult.data}")
|
||||
|
||||
val lastSnippetClass = history.peek()?.item?.first
|
||||
|
||||
Reference in New Issue
Block a user