summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorclhodapp <clhodapp1@gmail.com>2014-05-29 21:44:46 -0700
committerclhodapp <clhodapp1@gmail.com>2014-06-10 21:19:33 -0700
commit1a20152e97fe772e299fa3eb2608bedcea95cb82 (patch)
treee656a2998b292b9189f8a6e6072beaf63e24fed1 /doc
parentda2896c4e5a1e037bc3a473bc9d1689378816a32 (diff)
downloadscala-1a20152e97fe772e299fa3eb2608bedcea95cb82.tar.gz
scala-1a20152e97fe772e299fa3eb2608bedcea95cb82.tar.bz2
scala-1a20152e97fe772e299fa3eb2608bedcea95cb82.zip
SI-6967 Fix ClassTag unapply for primitives
This commit fixes the behavior of ClassTag's Any-accepting unapply overload. Previously, ClassTag had overloads of unapply that accepted all of the Java primitive aliases (language-supported magic classes extending AnyVal), as well as an implementation that accepted an Any. All of the AnyVal-accepting (more specific) versions of the methods worked correctly. However, the Any-accepting version incorrectly handled these types. For example, ClassTag.Int.unapply(3) would return Some(3) (through the Int-accepting overload), while ClassTag.Int.unapply(3: Any) would return None (through the Any-accepting overload). This commit unifies these behaviors, making ClassTag.Int.unapply(3: Any) return Some(3). It accomplishes this by adding a pattern match on the type of that method's argument, which will delegate to one of the more-specifically-typed overloads if possible. It also improves the formatting of the code a bit. One thing to note (though I doubt anyone will ever do this based on this message) is that the AnyVal-subtype-accepting overloads should be removed in Scala 2.12, as they are unneeded. I placed a note to this effect into the code.
Diffstat (limited to 'doc')
0 files changed, 0 insertions, 0 deletions