Closed
Description
Compiler version
3.0.0 and 3.0.1
Minimized code
intf.java
interface Intf {
public void thing(int x);
public void thing(String... y);
}
impl.scala
class Impl extends Intf {
override def thing(x: Int) = ???
override def thing(y: String*) = ???
}
Output
[error] -- Error: /home/score/varargs-overloading/src/main/scala/impl.scala:1:6 --------
[error] 1 |class Impl extends Intf {
[error] | ^
[error] |class Impl needs to be abstract, since def thing(y: Array[? <: String]): Unit in trait Intf is not defined
[error] |(The class implements members with different types: List(override def thing(y: Seq[String]): Nothing in class Impl, override def thing(x: Int): Unit in class Impl)%
[error] | %)
[error] -- [E038] Declaration Error: /home/score/varargs-overloading/src/main/scala/impl.scala:3:15
[error] 3 | override def thing(y: String*) = ???
[error] | ^
[error] | method thing has a different signature than the overridden declaration
Expectation
Like in Scala 2, this should be valid code.
The error can be worked around by using an Array
type directly (not compatible with scala 2's behaviour) or by renaming/removing the overloads on the interface.