12

当与Scala的相关方法类型的打,我遇到了默认的方法的参数冲突:相关方法类型的冲突

abstract class X { 
    type Y 
    case class YY(y: Y) 
} 

object XX extends X { 
    type Y = String 
} 

trait SomeTrait { 
    def method(x: X)(y: x.YY, default: Int = 3): Unit 
} 

object SomeObject extends SomeTrait { 
    def method(x: X)(y: x.YY, default: Int): Unit = {} 

    method(XX)(XX.YY("abc")) // fails to compile 
} 

的消息是:

[error] found : me.alexbool.XX.YY 
[error] required: x$1.YY 
[error] Error occurred in an application involving default arguments. 
[error]  method(XX)(XX.YY("abc")) // fails to compile 

如果我删除了参数使用方法定义和实现的默认值,示例编译成功。我究竟做错了什么?这是一个错误吗?

P.S.我正在使用Scala 2.11.4

+0

对我来说看起来像一个bug。 –

回答