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> {
77
77
method : Method
78
78
): SingleArgFastKFunction <T > = when {
79
79
// KParameter.Kind.EXTENSION_RECEIVERの要求が有れば確定で拡張関数
80
- parameters[0 ].kind == KParameter .Kind .EXTENSION_RECEIVER -> {
80
+ parameters[0 ].kind == KParameter .Kind .EXTENSION_RECEIVER ->
81
81
// 対象が拡張関数なら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
+ }
88
87
// javaMethodのパラメータサイズとKFunctionのパラメータサイズが違う場合も拡張関数
89
88
// インスタンスが設定されていれば高速呼び出し、そうじゃなければ通常の関数呼び出し
90
89
method.parameters.size != parameters.size ->
91
90
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
+ }
93
96
? : Function (parameters[0 ], function)
94
97
// トップレベル関数
95
98
else -> TopLevelFunction (parameters[0 ], method)
You can’t perform that action at this time.
0 commit comments