Dependent method types conflict with default arguments
Asked Answered
O

1

12

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

Officiary answered 3/1, 2015 at 17:49 Comment(1)
Looks like a bug to me.Unwarranted
O
7

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

Officiary answered 3/1, 2015 at 21:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.