Dependent method types conflict with default arguments

159 views Asked by At

When playing with scala's dependent method types, I encountered a conflict with default method parameters:

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
}

The message is:

[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

If I remove the argument with default value from method definition and implementation, the example compiles successfully. What am I doing wrong? Is it a bug?

P.S. I am using Scala 2.11.4

1

There are 1 answers

0
Alexander Bulaev On

Half an hour of googling and I have an answer. Yes, this is a bug. https://issues.scala-lang.org/browse/SI-7371