Closed
Description
Compiler version
3.1.3
Minimized code
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
Seq(1) match {
case value unapplyer () => println(value)
}
Seq(42, 28, 17) match {
case value unapplyer (x, y) => println(x + y)
}
}
Output
-- Error: test/files/neg/t12110.scala:20:25 ----------------------------------------------------------------------------
20 | case value unapplyer () => println(value)
| ^^
| Values of types Unit and Int cannot be compared with == or !=
-- [E008] Not Found Error: test/files/neg/t12110.scala:23:45 -----------------------------------------------------------
23 | case value unapplyer (x, y) => println(x + y)
| ^^^
| value + is not a member of Any, but could be made available as an extension method.
|
| One of the following imports might make progress towards fixing the problem:
|
| import math.Fractional.Implicits.infixFractionalOps
| import math.Integral.Implicits.infixIntegralOps
| import math.Numeric.Implicits.infixNumericOps
|
2 errors found
Expectation
A less puzzling error message. Scala 2 -Xsource:3
fails to warn in the second, multiarg case.
I'm not sure the feature status is mentioned in the reference docs.
Via scala/bug#12110
The clean-up began at #4311