Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependent method types conflict with default arguments

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

like image 364
Alexander Bulaev Avatar asked Jan 03 '15 17:01

Alexander Bulaev


1 Answers

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

like image 167
Alexander Bulaev Avatar answered Oct 24 '22 05:10

Alexander Bulaev