我有一个功能
fun <T> get(path: String, params: MutableMap<String, Any>? = null, headers: MutableMap<String, String>? = null, resolver: ResponseResolver<T>): HttpRequest<T>
哪个ResponseResolver是类型别名
typealias ResponseResolver<T> = (HttpResponse) -> T
当我调用如下所示的get方法时:
get("/somePath", mutableMapOf("key" to "value")){ httpResponse -> ......some code(Last line is a List<SomeClass>)
然后Intellij告诉我
Type inference failed:
fun <T> get
(
path: String,
params: MutableMap<String, Any>? = ...,
headers: MutableMap<String, String>? = ...,
resolver: ResponseResolver<T> /* = (HttpResponse) → T */
)
: HttpRequest<T>
cannot be applied to
(
String,
MutableMap<String, Any>,
(HttpResponse) → List<SomeClass>
)
我不确定在将闭包用作具有默认参数的某些函数的参数时是否有任何严格限制。
Kotlin并不完全知道mutableMapOf("key" to "value")
是什么。