This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
java/com/mapk/fastkfunction/spreadwrapper
kotlin/com/mapk/fastkfunction Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change
1
+ package com .mapk .fastkfunction .spreadwrapper ;
2
+
3
+ import kotlin .reflect .KFunction ;
4
+ import org .jetbrains .annotations .NotNull ;
5
+
6
+ public class ForKFunction <T > {
7
+ private final KFunction <T > kFunction ;
8
+
9
+ public ForKFunction (@ NotNull KFunction <T > kFunction ) {
10
+ this .kFunction = kFunction ;
11
+ }
12
+
13
+ public T call (Object [] args ) {
14
+ return kFunction .call (args );
15
+ }
16
+ }
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.mapk.fastkfunction
3
3
import com.mapk.fastkfunction.argumentbucket.ArgumentBucket
4
4
import com.mapk.fastkfunction.argumentbucket.BucketGenerator
5
5
import com.mapk.fastkfunction.spreadwrapper.ForConstructor
6
+ import com.mapk.fastkfunction.spreadwrapper.ForKFunction
6
7
import java.lang.reflect.Method
7
8
import java.lang.reflect.Modifier
8
9
import kotlin.reflect.KFunction
@@ -44,17 +45,18 @@ sealed class FastKFunction<T> {
44
45
private val function : KFunction <T >,
45
46
override val valueParameters : List <KParameter >
46
47
) : FastKFunction<T>() {
48
+ private val spreadWrapper = ForKFunction (function)
47
49
override val bucketGenerator = BucketGenerator (valueParameters, null )
48
50
49
51
override fun callBy (bucket : ArgumentBucket ): T = if (bucket.isFullInitialized()) {
50
- function .call(* bucket.getValueArray())
52
+ spreadWrapper .call(bucket.getValueArray())
51
53
} else {
52
54
function.callBy(bucket)
53
55
}
54
56
55
- override fun callByCollection (args : Collection <Any ?>): T = function .call(* args.toTypedArray())
57
+ override fun callByCollection (args : Collection <Any ?>): T = spreadWrapper .call(args.toTypedArray())
56
58
57
- override fun call (vararg args : Any? ): T = function .call(* args)
59
+ override fun call (vararg args : Any? ): T = spreadWrapper .call(args)
58
60
}
59
61
60
62
internal class TopLevelFunction <T >(
You can’t perform that action at this time.
0 commit comments