You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ticket/5082~/code/scala2 scala29
Welcome to Scala version 2.9.1.final (JavaHotSpot(TM) 64-BitServerVM, Java1.6.0_27).
Type in expressions to have them evaluated.
Type:help for more information.
scala>caseclassY(finalvarx:Int, finalprivatevary:String, finalvalz1:Boolean, finalprivatevalz2:Any)
defined classY
scala>defx=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 (JavaHotSpot(TM) 64-BitServerVM, Java1.6.0_27).
Type in expressions to have them evaluated.
Type:help for more information.
scala>caseclassY(finalvarx:Int, finalprivatevary:String, finalvalz1:Boolean, finalprivatevalz2:Any)
defined classY
scala>defx=Y.unapply(null)
x:Option[(Int, Boolean, String, Any)]
scala>valY(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.
overrideprotecteddeftupleSel(binder: Symbol)(i: Int):Tree= { importCODE._// caseFieldAccessors is messed up after typers (reversed, names mangled for non-public fields)// TODO: figure out why...valaccessors= binder.caseFieldAccessors
// luckily, the constrParamAccessors are still sorted properly, so sort the field-accessors using them// (need to undo name-mangling, including the sneaky trailing whitespace)valconstrParamAccessors= binder.constrParamAccessors
valoriginalAccessors= clazz.caseFieldAccessors
// private ones will have been renamed -- make sure they are entered// in the original order.defaccessors= clazz.caseFieldAccessors sortBy { acc =>
originalAccessors indexWhere { orig =>
(acc.name == orig.name) || (acc.name startsWith (orig.name append "$"))
}
}
Activity
scabug commentedon Jan 28, 2013
Imported From: https://issues.scala-lang.org/browse/SI-7035?orig=1
Reporter: @retronym
Affected Versions: 2.10.0
scabug commentedon Jan 28, 2013
@retronym said:
scabug commentedon Jan 28, 2013
@retronym said:
scabug commentedon Jan 28, 2013
@retronym said:
scala/scala#1997