Skip to content
This repository was archived by the owner on Jan 20, 2023. It is now read-only.

Commit 054f468

Browse files
committed
分割
1 parent 7e6aacb commit 054f468

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/kotlin/com/mapk/fastkfunction/FastKFunction.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,19 @@ class FastKFunction<T>(private val function: KFunction<T>, instance: Any?) {
1616
private val fullInitializedFunction: (Array<out Any?>) -> T
1717
private val bucketGenerator: BucketGenerator
1818

19-
init {
20-
// 引数を要求しないか、複数のインスタンスを求める場合エラーとする
21-
val parameters: List<KParameter> = function.parameters.apply {
19+
companion object {
20+
private fun List<KParameter>.checkParameters(instance: Any?) = apply {
2221
if (isEmpty() || (instance != null && size == 1))
2322
throw IllegalArgumentException("This function is not require arguments.")
2423

2524
if (3 <= size && get(0).kind != KParameter.Kind.VALUE && get(1).kind != KParameter.Kind.VALUE)
2625
throw IllegalArgumentException("This function is require multiple instances.")
2726
}
27+
}
28+
29+
init {
30+
// 引数を要求しないか、複数のインスタンスを求める場合エラーとする
31+
val parameters: List<KParameter> = function.parameters.checkParameters(instance)
2832

2933
// この関数には確実にアクセスするためアクセシビリティ書き換え
3034
function.isAccessible = true

0 commit comments

Comments
 (0)