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

Commit 7fe0309

Browse files
committed
インスタンスパラメータの要求の有無で渡すパラメータを変える必要が有ったため修正
1 parent 61dbdd1 commit 7fe0309

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,12 @@ sealed class SingleArgFastKFunction<T> {
9696
): SingleArgFastKFunction<T> {
9797
val instance = inputtedInstance ?: method.declaringObject
9898

99-
return if (parameters[0].kind == KParameter.Kind.INSTANCE || instance != null) {
100-
instance ?: throw IllegalArgumentException("Function requires INSTANCE parameter, but is not present.")
101-
102-
InstanceFunction(parameters[1], method, instance)
103-
} else {
104-
Function(parameters[0], function)
99+
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.")
103+
instance != null -> InstanceFunction(parameters[0], method, instance)
104+
else -> Function(parameters[0], function)
105105
}
106106
}
107107

0 commit comments

Comments
 (0)