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

Commit f2e7559

Browse files
committed
呼び出しを簡略化
1 parent db8454a commit f2e7559

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/main/kotlin/com/wrongwrong/mapk/core/ParameterForMap.kt

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,11 @@ private fun <T : Any> creatorsFromCompanionObject(clazz: KClass<T>): Set<Pair<KC
6666
companionObject::class.functions
6767
.filter { it.annotations.any { annotation -> annotation is KConverter } }
6868
.map { function ->
69-
function as KFunction<T>
69+
// isAccessibleの書き換えはKotlinの都合で先に行う必要が有る
7070
function.isAccessible = true
71+
val func: KFunction<T> = CompanionKFunction(function, companionObject) as KFunction<T>
7172

72-
val params = function.parameters
73-
if (params.size != 2) {
74-
throw IllegalArgumentException("This function is not compatible num of arguments.")
75-
}
76-
77-
(params.single { param -> param.kind == KParameter.Kind.VALUE }.type.classifier as KClass<*>) to
78-
CompanionKFunction(function, companionObject)
73+
(func.parameters.single().type.classifier as KClass<*>) to func
7974
}.toSet()
8075
} ?: emptySet()
8176
}

0 commit comments

Comments
 (0)