Skip to content

Adding varargs on override method fails to compile #9911

Closed
@DieBauer

Description

@DieBauer

Minimized code

import scala.annotation.varargs

trait A {
  def bla(as: String*): Unit
}

object B extends A {
  @varargs
  override def bla(a: String*) = ()
}

Output

sbt:dotty-simple> compile
[info] Compiling 1 Scala source to /Users/Jens/Developer/chapter/dotty/chapter/target/scala-0.27/classes ...
[error] -- [E037] Declaration Error: /Users/Jens/Developer/chapter/dotty/chapter/src/main/scala/Varargs.scala:7:7 
[error] 7 |object B extends A {
[error]   |       ^
[error]   |       method bla overrides nothing
[error] one error found

Expectation

This compiles in scala 2.13, dotty 0.25, but breaks with dotty 0.26+.

Adding the @varargs also to the trait method does solve the issue.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions