Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regression pattern matcher analysis with object nested in parameterized class #8546

Closed
scabug opened this issue Apr 29, 2014 · 2 comments
Closed
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Apr 29, 2014

Regressed in: scala/scala#2440

Excellent test case comes from this report: https://groups.google.com/d/msg/scala-language/cj5ussiwPX0/iZEBEQLRxIMJ

package test

class F1() {
  private sealed abstract class T
  private case class A(m: Int) extends T
  private case class B() extends T
  private case object C extends T

  // No warnings here
  private def foo(t: T) = t match {
    case A(m) => println("A:" + m)
    case B() => println("B")
    case C => println("C")
  }

  def test(m: Int): Unit = {
    foo(A(m))
    foo(B())
    foo(C)
  }
}

class F2[M]() {
  private sealed abstract class T
  private case class A(m: M) extends T
  private case class B() extends T
  private case object C extends T

  // match may not be exhaustive. It would fail on the following input: C
  private def foo(t: T) = t match {
    case A(m) => println("A:" + m)
    case B() => println("B")
    case C => println("C")
  }

  def test(m: M): Unit = {
    foo(A(m))
    foo(B())
    foo(C)
  }

}

object Test {
  def main(args: Array[String]): Unit = {
    new F1().test(1)
    new F2[Int]().test(1)
  }
}
@scabug
Copy link
Author

scabug commented Apr 29, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8546?orig=1
Reporter: @retronym
Affected Versions: 2.10.2

@scabug
Copy link
Author

scabug commented Apr 29, 2014

@retronym said:
scala/scala#3705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants