Skip to content

Soundness issue with type pattern #1754

Closed
@smarter

Description

@smarter

This doesn't compile, as expected:

case class One[T](fst: T)

object Test {
  def good[T](e: One[T]) = e match {
    case One(_) =>
      val t: T = e.fst
      val nok: Nothing = t // error, as expected
  }
}

But this does:

case class One[T](fst: T)

object Test {
  def bad[T](e: One[T]) = e match {
    case foo: One[a] =>
      val t: T = e.fst
      val nok: Nothing = t // should not compile
  }
}

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