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

Commit e58add3

Browse files
committed
引数名の重複チェックを追加
1 parent 5c37373 commit e58add3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/main/kotlin/com/mapk/core/KFunctionForCall.kt

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import kotlin.reflect.KClass
1111
import kotlin.reflect.KFunction
1212
import kotlin.reflect.KParameter
1313
import kotlin.reflect.full.companionObjectInstance
14+
import kotlin.reflect.full.findAnnotation
1415
import kotlin.reflect.full.functions
1516
import kotlin.reflect.full.primaryConstructor
1617
import kotlin.reflect.jvm.isAccessible
1718
import org.jetbrains.annotations.TestOnly
18-
import kotlin.reflect.full.findAnnotation
1919

2020
class KFunctionForCall<T> internal constructor(
2121
@TestOnly
@@ -62,7 +62,15 @@ class KFunctionForCall<T> internal constructor(
6262
}
6363
acc
6464
}
65-
requiredParametersMap = requiredParameters.associateBy { it.name }
65+
66+
requiredParametersMap = HashMap<String, ValueParameter<*>>().apply {
67+
requiredParameters.forEach {
68+
if (containsKey(it.name))
69+
throw IllegalArgumentException("The argument name ${it.name} is duplicated.")
70+
71+
this[it.name] = it
72+
}
73+
}
6674
}
6775

6876
fun getArgumentAdaptor(): ArgumentAdaptor = ArgumentAdaptor(requiredParametersMap)

0 commit comments

Comments
 (0)