miniboxing-plugin
miniboxing-plugin copied to clipboard
Pattern-match duplication error
Found while minimizing #181.
$ cat gh-bug-182.scala
package miniboxing.tests.bug182
import annotation.tailrec
sealed abstract class ConsList[@miniboxed A] {
import ConsList._
def dropWhile(): ConsList[A] = this match {
case Cons(h, t) => t
}
}
object ConsList {
class Cons[@miniboxed A](val head: A, val tail: ConsList[A]) extends ConsList[A]
object Cons{
def unapply[@miniboxed A](x: Cons[A]): Option[(A, miniboxing.tests.bug181.ConsList[A])] =
if (x == null)
None
else
Some((x.head, x.tail))
}
}
$ mb-scalac gh-bug-182.scala
gh-bug-182.scala:8: error: type mismatch;
found : miniboxing.tests.bug181.ConsList[A(in method dropWhile)] where type A(in method dropWhile) >: A(in class ConsList) <: A(in class ConsList)
required: miniboxing.tests.bug182.ConsList[A(in class ConsList)]
case Cons(h, t) => t
^
gh-bug-182.scala:19: error: type mismatch;
found : miniboxing.tests.bug182.ConsList[A]
required: miniboxing.tests.bug181.ConsList[A]
Some((x.head, x.tail))
^
two errors found
Reopened, since this affects some version of the Scala compiler :/