-
Notifications
You must be signed in to change notification settings - Fork 21
Closed
Description
ticket/5082 ~/code/scala2 scala29
Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.
scala> case class Y(final var x: Int, final private var y: String, final val z1: Boolean, final private val z2: Any)
defined class Y
scala> def x = Y.unapply(null)
x: Option[(Int, String, Boolean, Any)]
scala> ticket/5082 ~/code/scala2 scala-hash v2.10.0
[info] v2.10.0 => /Users/jason/usr/scala-v2.10.0-0-g18481ce
Welcome to Scala version 2.10.0-20121205-112020-18481cef9b (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.
scala> case class Y(final var x: Int, final private var y: String, final val z1: Boolean, final private val z2: Any)
defined class Y
scala> def x = Y.unapply(null)
x: Option[(Int, Boolean, String, Any)]
scala> val Y(a, b, c, d) = Y(0, "", true, new {})
a: Int = 0
b: String = ""
c: Boolean = true
d: Any = $anon$1@56801919
scala> Y.unapply(Y(0, "", true, new {}))
res0: Option[(Int, Boolean, String, Any)] = Some((0,true,,$anon$1@2eac0b4))See also #5082. My proposed patch for it happens to reverse this regression.
Pattern matching, which bypasses the synthesized unapply method seems, superficially, to be immune. I seem to remember some code in there that corrected for out-of-order case accessors, but I can't find it. It does use caseAccessors when producing counter-examples, which may be subject to this bug, too.