Skip to content

Infix sequence wildcard can't match empty sequence in 2.13 (empty multiarg infix not supported) #12110

Closed
scala/scala
#10098
@semkagtn

Description

@semkagtn

reproduction steps

Scala version: 2.13.3

object Main
  extends App {

  class Unapplyer {
    def unapplySeq(seq: Seq[Int]): Option[(Int, Seq[Int])] =
      if (seq.isEmpty) None else Some((seq.head, seq.tail))
  }
  val unapplyer = new Unapplyer

  /* 
     v2.12.12:
       prints "1"
     v2.13.3:
       type mismatch;
        found   : Unit
        required: Int
           case value unapplyer () => println(value)
   */
  Seq(1) match {
    case value unapplyer () => println(value)
  }
}

problem

The code above can't be compiled with Scala 2.13.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions