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

Higher-kinded type alias may cause incorrect unreachable code warning #6771

Closed
scabug opened this issue Dec 5, 2012 · 3 comments
Closed

Higher-kinded type alias may cause incorrect unreachable code warning #6771

scabug opened this issue Dec 5, 2012 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

@scabug scabug commented Dec 5, 2012

I came across an unreachable code warning which should not be present, in Scala 2.10.0-RC3:

object Test {
  type Id[X] = X

  def main(args: Array[String]) {
    val a: Id[Option[Int]] = None

    a match {
      case Some(x) => println(x)
      case None => println("Nothing")
    }
  }
}
$ sbt run
[info] Set current project to default-2e4ad8 (in build file:../)
[info] Compiling 1 Scala source to .../target/scala-2.10/classes...
[warn] .../src/main/scala/Test.scala:9: unreachable code
[warn]       case None => println("Nothing")
[warn]                           ^
[warn] one warning found
[info] Running Test 
Nothing

If, instead, the code looks like

type Id[X] = Option[X]

and

val a: Id[Int] = None

no unreachable code warning appears.

@scabug
Copy link
Author

@scabug scabug commented Dec 5, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6771?orig=1
Reporter: Gary Coady (garycoady)
Affected Versions: 2.10.0-RC3

@scabug
Copy link
Author

@scabug scabug commented Dec 5, 2012

@paulp said:
Patch pending.

@scabug
Copy link
Author

@scabug scabug commented Apr 24, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants