Kotlin 扩展属性:函数声明必须具有名称未解析引用:get
我使用扩展功能扩展2.响应对象: 片段: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
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)