2
package bug
import groovy.transform.CompileStatic
@CompileStatic
class BugCheck
{
static void main(String[] args)
{
new BugCheck()
}
BugCheck()
{
new Child().method(1f) // causes the problem
}
class Parent
{
void method(float f, boolean b=true)
{
println("Parent")
}
}
class Child extends Parent
{
@Override
void method(float f)
{
println("Child")
}
}
}
編譯此片的代碼使用Groovy 2.3.4導致以下錯誤:錯誤? 「參考方法不明確」在Groovy
/mirror/dev/Groovy/src/bug/BugCheck.groovy: 17:[靜態類型檢查] - 對方法的引用不明確。無法在[void bug.BugCheck $ Child#method(float),void bug.BugCheck $ Child#method(float)]之間進行選擇
這是Groovy中的錯誤,還是我錯過了某些東西?
Snell對我來說就像一個bug。默認參數將解析爲兩個方法,其中一個在子類中被覆蓋。可能值得投入常規吉拉 –