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

Commit 144ce64

Browse files
committed
private関数に対してもマップ呼び出しができるように修正
1 parent 46d69ec commit 144ce64

File tree

1 file changed

+4
-0
lines changed
  • src/main/kotlin/com/wrongwrong/mapk/core

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import kotlin.reflect.KVisibility
1111
import kotlin.reflect.full.isSuperclassOf
1212
import kotlin.reflect.full.memberProperties
1313
import kotlin.reflect.full.primaryConstructor
14+
import kotlin.reflect.jvm.isAccessible
1415

1516
class KMapper<T: Any>(private val function: KFunction<T>, propertyNameConverter: (String) -> String = { it }) {
1617
constructor(clazz: KClass<T>, propertyNameConverter: (String) -> String = { it }): this(
@@ -27,6 +28,9 @@ class KMapper<T: Any>(private val function: KFunction<T>, propertyNameConverter:
2728
parameters = params
2829
.map { ParameterForMap(it, propertyNameConverter) }
2930
.toSet()
31+
32+
// private関数に対してもマッピングできなければ何かと不都合があるため、accessibleは書き換える
33+
function.isAccessible = true
3034
}
3135

3236
fun map(srcMap: Map<String, Any?>): T {

0 commit comments

Comments
 (0)