【发布时间】:2017-03-03 06:08:28
【问题描述】:
当我尝试构建我的 Kotlin 项目时,我在 Idea 中得到以下 error:
Error:Kotlin: [Internal Error] org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression at (60,19) in E:/altruix-is/src/main/kotlin/com/mycompany/myproduct/capsulecrm/CapsuleCrmSubsystem.kt:
client.execute(req)
[...]
Caused by: java.lang.UnsupportedOperationException: doSubstitute with no original should not be called for synthetic extension
at org.jetbrains.kotlin.synthetic.SamAdapterFunctionsScope$MyFunctionDescriptor.doSubstitute(SamAdapterFunctionsScope.kt:165)
at org.jetbrains.kotlin.descriptors.impl.FunctionDescriptorImpl$CopyConfiguration.build(FunctionDescriptorImpl.java:553)
at org.jetbrains.kotlin.load.java.ErasedOverridabilityCondition.isOverridable(ErasedOverridabilityCondition.kt:47)
错误似乎发生在调用中
res = client.execute(req)
client 是 Apache HttpClient。
可以在here找到发生这种情况的源文件。
我向 JetBrains 提交了错误报告,但我需要进一步处理该项目,因此需要解决。请注意,直到昨天一切正常。昨天我把 Kotlin 插件升级到最新版本,可能是这个问题。
如何避免上述错误?
更新 1(03.03.2017 14:46 MSK):
这不起作用:
open fun addNote(note: String, compId: Long): ValidationResult {
val client = httpClient
if (client == null) {
return ValidationResult(false, "Internal error")
}
var res: CloseableHttpResponse? = null
var req: HttpUriRequest?
try {
req = composeAddNoteRequest(note, compId)
res = client.execute(req)
if (res.statusLine.statusCode != 201) {
logger.error("addNote(note='$note', compId=$compId): Wrong status code ${res.statusLine.statusCode}")
return ValidationResult(false, "Wrong status code (CRM interaction)")
}
return ValidationResult(true, "")
}
catch (throwable: Throwable) {
logger.error("addNote(note='$note', compId=$compId)", throwable)
return ValidationResult(false, "Database error")
} finally {
close(res)
}
return ValidationResult(false, "Internal logic error")
}
这行得通(区别在从顶部开始的第二行):
open fun addNote(note: String, compId: Long): ValidationResult {
val client = httpClient as CloseableHttpClient // Change
if (client == null) {
return ValidationResult(false, "Internal error")
}
var res: CloseableHttpResponse? = null
var req: HttpUriRequest?
try {
req = composeAddNoteRequest(note, compId)
res = client.execute(req)
if (res.statusLine.statusCode != 201) {
logger.error("addNote(note='$note', compId=$compId): Wrong status code ${res.statusLine.statusCode}")
return ValidationResult(false, "Wrong status code (CRM interaction)")
}
return ValidationResult(true, "")
}
catch (throwable: Throwable) {
logger.error("addNote(note='$note', compId=$compId)", throwable)
return ValidationResult(false, "Database error")
} finally {
close(res)
}
return ValidationResult(false, "Internal logic error")
}
【问题讨论】:
-
这就是为什么它是评论
标签: java intellij-idea kotlin