@@ -16,21 +16,21 @@ sealed class SingleArgFastKFunction<T> {
1616 internal class Constructor <T >(
1717 override val valueParameter : KParameter ,
1818 private val constructor : JavaConstructor <T >
19- ): SingleArgFastKFunction<T>() {
19+ ) : SingleArgFastKFunction<T>() {
2020 override fun call (arg : Any? ): T = constructor .newInstance(arg)
2121 }
2222
2323 internal class Function <T >(
2424 override val valueParameter : KParameter ,
2525 private val function : KFunction <T >
26- ): SingleArgFastKFunction<T>() {
26+ ) : SingleArgFastKFunction<T>() {
2727 override fun call (arg : Any? ): T = function.call(arg)
2828 }
2929
3030 internal class TopLevelFunction <T >(
3131 override val valueParameter : KParameter ,
3232 private val method : Method
33- ): SingleArgFastKFunction<T>() {
33+ ) : SingleArgFastKFunction<T>() {
3434 @Suppress(" UNCHECKED_CAST" )
3535 override fun call (arg : Any? ): T = method.invoke(null , arg) as T
3636 }
@@ -39,7 +39,7 @@ sealed class SingleArgFastKFunction<T> {
3939 override val valueParameter : KParameter ,
4040 private val method : Method ,
4141 private val extensionReceiver : Any
42- ): SingleArgFastKFunction<T>() {
42+ ) : SingleArgFastKFunction<T>() {
4343 @Suppress(" UNCHECKED_CAST" )
4444 override fun call (arg : Any? ): T = method.invoke(null , extensionReceiver, arg) as T
4545 }
@@ -48,7 +48,7 @@ sealed class SingleArgFastKFunction<T> {
4848 override val valueParameter : KParameter ,
4949 private val method : Method ,
5050 private val instance : Any
51- ): SingleArgFastKFunction<T>() {
51+ ) : SingleArgFastKFunction<T>() {
5252 @Suppress(" UNCHECKED_CAST" )
5353 override fun call (arg : Any? ): T = method.invoke(instance, arg) as T
5454 }
@@ -81,9 +81,10 @@ sealed class SingleArgFastKFunction<T> {
8181 }
8282 // javaMethodのパラメータサイズとKFunctionのパラメータサイズが違う場合も拡張関数
8383 // インスタンスが設定されていれば高速呼び出し、そうじゃなければ通常の関数呼び出し
84- method.parameters.size != parameters.size -> instance
85- ?.let { TopLevelExtensionFunction (parameters[0 ], method, instance) }
86- ? : Function (parameters[0 ], function)
84+ method.parameters.size != parameters.size ->
85+ instance
86+ ?.let { TopLevelExtensionFunction (parameters[0 ], method, instance) }
87+ ? : Function (parameters[0 ], function)
8788 // トップレベル関数
8889 else -> TopLevelFunction (parameters[0 ], method)
8990 }
@@ -97,9 +98,10 @@ sealed class SingleArgFastKFunction<T> {
9798 val instance = inputtedInstance ? : method.declaringObject
9899
99100 return when {
100- parameters[0 ].kind == KParameter .Kind .INSTANCE -> instance
101- ?.let { InstanceFunction (parameters[1 ], method, it) }
102- ? : throw IllegalArgumentException (" Function requires INSTANCE parameter, but is not present." )
101+ parameters[0 ].kind == KParameter .Kind .INSTANCE ->
102+ instance
103+ ?.let { InstanceFunction (parameters[1 ], method, it) }
104+ ? : throw IllegalArgumentException (" Function requires INSTANCE parameter, but is not present." )
103105 instance != null -> InstanceFunction (parameters[0 ], method, instance)
104106 else -> Function (parameters[0 ], function)
105107 }
0 commit comments