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

spurious unreachability error due to Product not conforming to AnyRef #6022

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

spurious unreachability error due to Product not conforming to AnyRef #6022

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

Comments

@scabug
Copy link

@scabug scabug commented Jul 3, 2012

(null: Any) match {
  case x: AnyRef if false =>
  case list: Option[Int] =>
  case product: Product => // change Product to String and it's all good
}

due to the way the subtyping relations are rendered as boolean propositions, we get a contradiction, and the error shows up in an unexpected case:

[adriaan@lampmac13 scala (topic/virtpatmat-dev)]$ qs -Ypatmat-debug
Welcome to Scala version 2.10.0-20120705-095737-584eeecd82 (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_33).
Type in expressions to have them evaluated.
Type :help for more information.

scala> (null: Any) match {
     |   case x: AnyRef if false => // has to be AnyRef
     |   case list: Option[Int] => // has to be a product-derived class
     |   case product: Product => // apparently Product is not a subtype of AnyRef (or AnyVal)
     | }

<snip>

NOT excludes: (Product,Option[_])
excludes    : (Product,Product,AnyRef,AnyRef,false,false,false,false)
excludes    : (Product,Product,null,Null(null),false,false,true,true)

eq axioms for: Product
excluded: List(V1=AnyRef#2, V1=null#1)
implied: List()
NOT excludes: (Option[_],Product)
NOT excludes: (Option[_],AnyRef)
excludes    : (Option[_],Option[_],null,Null(null),false,false,true,true)

eq axioms for: Option[_]
excluded: List(V1=null#1)
implied: List(V1=Product#4, V1=AnyRef#2)
NOT excludes: (AnyRef,Option[_])
excludes    : (AnyRef,AnyRef,null,Null(null),false,false,true,true)

eq axioms for: AnyRef
excluded: List(V1=null#1)
implied: List()

eq axioms for: null
excluded: List()
implied: List()
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 3, 2012

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Jul 6, 2012

@adriaanm said (edited on Jul 12, 2012 6:54:46 AM UTC):
scala/scala#874

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 8, 2012

@adriaanm said:
seems to have regressed without being caught by the test (grep for "unreachable code" in https://scala-webapps.epfl.ch/jenkins/job/scala-nightly-main/1514/consoleText)

@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 8, 2012

@adriaanm said (edited on Aug 8, 2012 1:55:27 PM UTC):
this should not warn:

trait A
trait B
trait C
trait AB extends B with A

object Test extends App {
  def foo(x: Any) = x match {
    case _ : C  => println("C")
    case _ : AB => println("AB")
    case _ : B  => println("B")
    case _ : A  => println("A")
  }

  foo(new A {})
  foo(new B {})
  foo(new AB{})
  foo(new C {})
}

prints:

A
B
AB
C
@scabug

This comment has been minimized.

Copy link
Author

@scabug scabug commented Aug 10, 2012

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.