6

I have this class:

case class Columna[T](nombre: String)

class Tabla {
    def leeTodo[T](col: Columna[T], filtro: String, orderBy: String = "") = ...

    def leeTodo[T0, T1](col0: Columna[T0], col1: Columna[T1], filtro: String, orderBy: String = "") = ...

    def leeTodo[T0, T1, T2](col0: Columna[T0], col1: Columna[T1], col2: Columna[T2], filtro: String, orderBy: String = "") = ...

}

object admver extends Tabla {
}

This code used to compile with Scala 2.10.4. Now, I'm trying Scala 2.11.2, and I get this error message:

Error:(3, 8) in object admver, multiple overloaded alternatives of method leeTodo define default arguments.
The members with defaults are defined in class Tabla in package bd and class Tabla in package bd and class Tabla in package bd and class Tabla in package bd and class Tabla in package bd and class Tabla in package bd.

I think that there is no ambiguity between the different overloads.

I wonder if this is a bug in Scala 2.11 or a new "feature".

I've seen some old questions about the subject:

but don't know if they still apply.

Community
  • 1
  • 1
david.perez
  • 6,090
  • 4
  • 34
  • 57
  • The two old questions you mention do still apply. It is forbidden to declare two overloaded methods that both have default arguments. – sjrd Jul 28 '14 at 09:41
  • 1
    Then why does it compile with Scala 2.10.4 and doesn't with 2.11.2? Aren't they backwards compatible in source code?. I think my use case is legitimate. – david.perez Jul 28 '14 at 10:07
  • 1
    The Scala style guide recommends you use the alphabet for generics rather than `T` like in Java, so it should really be `leeTodo[A, B, C]`, rather than `leeTodo[T0, T1, T2]` – Electric Coffee Jul 28 '14 at 11:57
  • In this case I have overloads for a large number of parameters like col0, col1, col2, col3, col4, ... and using T0, T1, ... makes easier to create them. I just have to increment the digits. – david.perez Jul 28 '14 at 12:44
  • Probably, I'll report it as a bug in Scala 2.11. – david.perez Jul 29 '14 at 11:28
  • The same error with Scala 2.11.5 :-( – david.perez Feb 25 '15 at 14:38
  • This is annoying. Is it considered a bug? – douglaz Dec 07 '15 at 17:29

0 Answers0