-
Notifications
You must be signed in to change notification settings - Fork 22
Open
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)minimizedpatmatshould compile
Milestone
Description
sealed trait Base
case class Up() extends Base
case class Down() extends Base
sealed trait Tracker[B <: Base] {
def bar = this match {
case UpTracker() => ???
case DownTracker() => ???
}
}
case class UpTracker() extends Tracker[Up]
case class DownTracker() extends Tracker[Down]produces
PatternMatch.scala:8: error: constructor cannot be instantiated to expected type;
found : UpTracker
required: Tracker[B]
case UpTracker() => ???
^
PatternMatch.scala:9: error: constructor cannot be instantiated to expected type;
found : DownTracker
required: Tracker[B]
case DownTracker() => ???
^
two errors foundThis does not occur if we move the method into a separate object:
sealed trait Base
case class Up() extends Base
case class Down() extends Base
sealed trait Tracker[B <: Base]
case class UpTracker() extends Tracker[Up]
case class DownTracker() extends Tracker[Down]
object Foo {
def bar[B <: Base](t: Tracker[B]) = t match {
case UpTracker() => ???
case DownTracker() => ???
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
fixed in Scala 3This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)This issue does not exist in the Scala 3 compiler (https://github.com/lampepfl/dotty/)minimizedpatmatshould compile