0
我想重寫Groovy中的靜態getAt
運算符。它運行良好,但我被IntelliJ中的惡意警告難住了。Groovy重載靜態getAt(下標)運算符
class SubscriptTest {
static def map = [
(SubscriptKey.ONE) : 'one',
(SubscriptKey.TWO) : 'two',
(SubscriptKey.THREE): 'three',
]
static Object getAt(SubscriptKey key) {
map[key]
}
}
enum SubscriptKey {
ONE,
TWO,
THREE
}
當我運行
它打印one
。但是我也在IntelliJ中得到了下面的警告。在 'org.codehaus.groovy.runtime.DefaultGroovyMethods'
'getAt' 不能應用於 '(SubscriptKey)'
不知道如何解決/禁止這種警告。
我認爲這只是的IntelliJ犯錯 –
我也認爲這是一個方式的IntelliJ分析你的代碼,並試圖匹配'與getAt'爲例[DefaultGroovyMethods] (http://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html)作爲一種解決方法,您可以嘗試在編輯器中查找和禁用檢查規則。 – luka5z