Refactor and fixes after review
improving script constructor search algorithm - now default params should be supported remove prefix Customized- from scripts ModuleInfo-related classes refactoring ideaModuleInfos after review refactoring ResolveSessionProvider construction for readability refactoring KotlinScriptConfigurationManager after review fixing KotlinScriptDefinitionProvider after review
This commit is contained in:
+8
-2
@@ -317,8 +317,14 @@ object KotlinToJVMBytecodeCompiler {
|
||||
catch (e: java.lang.NoSuchMethodException) {
|
||||
for (ctor in scriptClass.kotlin.constructors) {
|
||||
val (ctorArgs, scriptArgsLeft) = ctor.parameters.fold(Pair(emptyList<Any>(), scriptArgs), ::foldingFunc)
|
||||
if (ctorArgs.size == ctor.parameters.size && (scriptArgsLeft == null || scriptArgsLeft.isEmpty()))
|
||||
return ctor.call(*ctorArgs.toTypedArray())
|
||||
if (ctorArgs.size <= ctor.parameters.size && (scriptArgsLeft == null || scriptArgsLeft.isEmpty())) {
|
||||
val argsMap = ctorArgs.zip(ctor.parameters) { a, p -> Pair(p, a) }.toMap()
|
||||
try {
|
||||
return ctor.callBy(argsMap)
|
||||
}
|
||||
catch (e: Exception) { // TODO: find the exact exception type thrown then callBy fails
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
|
||||
Reference in New Issue
Block a user