This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
src/main/kotlin/com/mapk/fastkfunction Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -8,8 +8,10 @@ import com.mapk.fastkfunction.spreadwrapper.ForMethod
8
8
import org.jetbrains.annotations.TestOnly
9
9
import java.lang.reflect.Method
10
10
import java.lang.reflect.Modifier
11
+ import kotlin.reflect.KClass
11
12
import kotlin.reflect.KFunction
12
13
import kotlin.reflect.KParameter
14
+ import kotlin.reflect.full.isSuperclassOf
13
15
import kotlin.reflect.jvm.isAccessible
14
16
import kotlin.reflect.jvm.javaConstructor
15
17
import kotlin.reflect.jvm.javaMethod
@@ -181,6 +183,13 @@ sealed class FastKFunction<T> {
181
183
182
184
return if (parameters[0 ].kind == KParameter .Kind .INSTANCE ) {
183
185
instance ? : throw IllegalArgumentException (" Function requires INSTANCE parameter, but is not present." )
186
+ val instanceClazz = instance::class
187
+
188
+ (parameters[0 ].type.classifier as KClass <* >).also {
189
+ if (! it.isSuperclassOf(instanceClazz))
190
+ throw IllegalArgumentException (" INSTANCE parameter required ${it.simpleName} , " +
191
+ " but ${instanceClazz.simpleName} is present." )
192
+ }
184
193
185
194
val generator = BucketGenerator (parameters, instance)
186
195
val valueParameters = parameters.subList(1 , parameters.size)
You can’t perform that action at this time.
0 commit comments