Skip to content

Typing varargs in pattern position #4790

Open
@allanrenucci

Description

@allanrenucci
import scala.collection.immutable

class Test {
  def foo(as: immutable.Seq[Int]) = {
    val List(_, bs: _*) = as
    val cs: collection.Seq[Int] = bs
  }
}
> dotc -d out tests/allan/Test.scala                                                                                                                                      13:14
-- [E007] Type Mismatch Error: tests/allan/Test.scala:47:34 --------------------
47 |    val cs: collection.Seq[Int] = bs
   |                                  ^^
   |                                  found:    Seq[Any](bs)
   |                                  required: Seq[Int]
   |                                  
one error found

But it does compile with -language:Scala2...

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions