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

Commit 1701959

Browse files
committed
receiverの型チェックを追加
1 parent 3378ae6 commit 1701959

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ sealed class FastKFunction<T> {
150150
parameters[0].kind == KParameter.Kind.EXTENSION_RECEIVER -> {
151151
// 対象が拡張関数ならinstanceはreceiver、指定が無ければエラー
152152
instance.instanceOrThrow(KParameter.Kind.EXTENSION_RECEIVER).let {
153+
checkInstanceClass(parameters[0].clazz, it::class)
154+
153155
val generator = BucketGenerator(parameters, it)
154156
val valueParameters = parameters.subList(1, parameters.size)
155157

@@ -161,6 +163,8 @@ sealed class FastKFunction<T> {
161163
method.parameters.size != parameters.size ->
162164
instance
163165
?.let {
166+
checkInstanceClass(method.parameters[0].type.kotlin, it::class)
167+
164168
// KFunctionとしては値パラメータを求めていないため、バケツにはインスタンスを設定しない
165169
TopLevelExtensionFunction(function, method, it, BucketGenerator(parameters, null), parameters)
166170
} ?: Function(function, parameters)

0 commit comments

Comments
 (0)