Skip to content

Commit

Permalink
Revert "call the primaryConstructor without arguments"
Browse files Browse the repository at this point in the history
This reverts commit f2ad444.
In some cases the script instance is needed as an argument for some constructors
  • Loading branch information
seelchen committed Sep 11, 2023
1 parent fd5b91a commit d396e79
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class SpecEvaluator {
// TODO: check for all implementations!
implementationsAndInstances
.filter { (it, _) -> it.createType().isSubtypeOf(param.type) }
.mapNotNull { (it, _) ->
.map { (it, paramInstance) ->
val primaryConstructor =
checkNotNull(it.primaryConstructor) {
"Could not create an instance of ${it.qualifiedName} to pass to rule " +
Expand All @@ -88,13 +88,13 @@ class SpecEvaluator {
"Could not create an instance of ${it.qualifiedName} to pass to rule " +
"\"${rule.name}\" because it's primary constructor expects arguments. Aborting."
}
// TODO: how do we access primaryConstructor.arity ? -> then we would
// not need the try..catch
try {
primaryConstructor.call()
primaryConstructor.call(paramInstance)
} catch (e: IllegalArgumentException) {
logger.debug {
"Calling constructor '$primaryConstructor' without arguments failed ($e)"
}
null
logger.debug { "Called constructor '$primaryConstructor' without paramInstance ($e)" }
primaryConstructor.call()
}
}[0]
}
Expand Down

0 comments on commit d396e79

Please sign in to comment.