Alk*_*dis 7 inheritance kotlin
我尝试在 kotlin 中创建一个自定义异常,并且还实现了 GraphQLError 接口,该接口需要 getMessage() 方法。
如果我尝试实现该方法,我的 IDE 会警告我:
Accidental override: The following declarations have the same JVM signature (getMessage()Ljava/lang/String;):
public open fun <get-message>(): String? defined in eu.mojo.presentation2018.error.ShopException
public open fun getMessage(): String defined in eu.mojo.presentation2018.error.ShopException
Run Code Online (Sandbox Code Playgroud)
但如果我删除它:
Class 'ShopException' is not abstract and does not implement abstract member
public abstract fun getMessage(): String! defined in graphql.GraphQLError
Run Code Online (Sandbox Code Playgroud)
我在网上搜索了解决方案,但都需要对导致冲突的字段“消息”进行一些控制。在我的情况下,此控件不存在,因为字段消息是在我尝试扩展的 Exception 类中定义的。
这是我的类定义:
class ShopException(code:ErrorCode) : Exception(), GraphQLError {...}
Run Code Online (Sandbox Code Playgroud)
目前(Kotlin 1.2.61)这是不可能的。
以下是有关该问题的一些问题,这些问题可能尚未得到足够的关注(有些问题只是相关的,因为他们更愿意提及其星座中的属性):
| 归档时间: |
|
| 查看次数: |
3183 次 |
| 最近记录: |