Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Kotlin 扩展属性:函数声明必须具有名称未解析引用:get_Kotlin_Kotlin Extension - Fatal编程技术网

Kotlin 扩展属性:函数声明必须具有名称未解析引用:get

Kotlin 扩展属性:函数声明必须具有名称未解析引用:get,kotlin,kotlin-extension,Kotlin,Kotlin Extension,我使用扩展功能扩展2.响应对象: 片段: public class ErrorResponse { private int code; private String message; private Response response; } import okhttp3.MediaType import okhttp3.Protocol import okhttp3.Request import okhttp3.ResponseBody import retrofit2

我使用扩展功能扩展2.响应对象:

片段:

public class ErrorResponse {
    private int code;
    private String message;
    private Response response;
}

import okhttp3.MediaType
import okhttp3.Protocol
import okhttp3.Request
import okhttp3.ResponseBody
import retrofit2.Response

fun Response<*>.errorResponse(): ErrorResponse {
    val errorResponse = ErrorUtils.parseError(this)
    return errorResponse
}

属性不需要括号。可能是这样的:

val Response<*>.errorResponse: ErrorResponse
   get() = ErrorUtils.parseError(this)
val Response<*>.errorResponse: ErrorResponse {
   get() = ErrorUtils.parseError(this)
}
Function declaration must have a name Unresolved reference: get
val Response<*>.errorResponse: ErrorResponse
   get() = ErrorUtils.parseError(this)