This repository was archived by the owner on Jan 20, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
src/main/kotlin/com/mapk/fastkfunction Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change @@ -77,19 +77,22 @@ sealed class SingleArgFastKFunction<T> {
7777 method : Method
7878 ): SingleArgFastKFunction <T > = when {
7979 // KParameter.Kind.EXTENSION_RECEIVERの要求が有れば確定で拡張関数
80- parameters[0 ].kind == KParameter .Kind .EXTENSION_RECEIVER -> {
80+ parameters[0 ].kind == KParameter .Kind .EXTENSION_RECEIVER ->
8181 // 対象が拡張関数ならinstanceはreceiver、指定が無ければエラー
82- TopLevelExtensionFunction (
83- parameters[1 ],
84- method,
85- instance.instanceOrThrow(KParameter .Kind .EXTENSION_RECEIVER )
86- )
87- }
82+ instance.instanceOrThrow(KParameter .Kind .EXTENSION_RECEIVER ).let {
83+ checkInstanceClass(parameters[0 ].clazz, it::class )
84+
85+ TopLevelExtensionFunction (parameters[1 ], method, it)
86+ }
8887 // javaMethodのパラメータサイズとKFunctionのパラメータサイズが違う場合も拡張関数
8988 // インスタンスが設定されていれば高速呼び出し、そうじゃなければ通常の関数呼び出し
9089 method.parameters.size != parameters.size ->
9190 instance
92- ?.let { TopLevelExtensionFunction (parameters[0 ], method, instance) }
91+ ?.let {
92+ checkInstanceClass(method.parameters[0 ].type.kotlin, it::class )
93+
94+ TopLevelExtensionFunction (parameters[0 ], method, instance)
95+ }
9396 ? : Function (parameters[0 ], function)
9497 // トップレベル関数
9598 else -> TopLevelFunction (parameters[0 ], method)
You can’t perform that action at this time.
0 commit comments