-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
This code compiles in Scala 2.11.4:
package typespatmat
sealed trait Box2[T]
final case class Int2(x: Int) extends Box2[Int]
final case class Str2(x: String)
extends Box2[String]
object Box2 {
def double2[T](x: Box2[T]): T = x match {
case Int2(i) => i * 2
case Str2(s) => s + s
}
}In dotty 8336a0d, this gives:
[info] Running dotty.tools.dotc.Main ../sbt-project/src/main/scala/Box2.scala
[error] ../sbt-project/src/main/scala/Box2.scala:10: error: type mismatch:
[error] found : Int
[error] required: T
[error] case Int2(i) => i * 2
[error] ^
[error] ../sbt-project/src/main/scala/Box2.scala:11: error: type mismatch:
[error] found : String
[error] required: T
[error] case Str2(s) => s + s
[error] ^
[error] two errors found