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
name based patmat doesn't typecheck get
#7850
Comments
Imported From: https://issues.scala-lang.org/browse/SI-7850?orig=1 |
@gkossakowski said: |
@paulp said:
|
@paulp said: |
@retronym said:
|
@retronym said:
|
@paulp said: % cat test/files/neg/t7850.scala
class Casey(a: Int) { def isEmpty = false; def get = this }
object Casey { def unapply(a: Casey) = Some(a) }
object Test {
def main(args: Array[String]) {
val Casey(x) = new Casey(1)
assert(x == 1, x)
}
}
% scalac210 -d /tmp test/files/neg/t7850.scala
test/files/neg/t7850.scala:7: warning: Casey and Int are unrelated: they will most likely never compare equal
assert(x == 1, x)
^
scalone warning found
% scala210 -cp /tmp Test
java.lang.AssertionError: assertion failed: Casey@1495c8c2
at scala.Predef$.assert(Predef.scala:179)
at Test$.main(t7850.scala:7)
at Test.main(t7850.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606) |
@retronym said (edited on Dec 15, 2013 8:11:57 PM UTC): Here's a CCE. We should check that class Casey(a: Int) { def isEmpty = this; def get = this }
object Casey { def unapply(a: Casey) = a }
object Test {
def main(args: Array[String]) {
val Casey(x) = new Casey(1)
}
}
|
@paulp said: |
@paulp said: |
ClassCastException ensues.
The text was updated successfully, but these errors were encountered: