summaryrefslogtreecommitdiff
path: root/test/files/run/t6318_primitives.check
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 /test/files/run/t6318_primitives.check
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 'test/files/run/t6318_primitives.check')
-rw-r--r--test/files/run/t6318_primitives.check54
1 files changed, 36 insertions, 18 deletions
diff --git a/test/files/run/t6318_primitives.check b/test/files/run/t6318_primitives.check
index b330f91276..4bc5e598eb 100644
--- a/test/files/run/t6318_primitives.check
+++ b/test/files/run/t6318_primitives.check
@@ -1,36 +1,54 @@
-true
+Checking if byte matches byte
Some(1)
-false
+Checking if byte matches short
None
-true
+Checking if class java.lang.Byte matches byte
Some(1)
-false
+Checking if short matches short
+Some(1)
+Checking if short matches char
None
-true
+Checking if class java.lang.Short matches short
+Some(1)
+Checking if char matches char
Some()
-false
+Checking if char matches int
None
-true
+Checking if class java.lang.Character matches char
+Some()
+Checking if int matches int
Some(1)
-false
+Checking if int matches long
None
-true
+Checking if class java.lang.Integer matches int
Some(1)
-false
+Checking if long matches long
+Some(1)
+Checking if long matches float
None
-true
+Checking if class java.lang.Long matches long
+Some(1)
+Checking if float matches float
Some(1.0)
-false
+Checking if float matches double
None
-true
+Checking if class java.lang.Float matches float
Some(1.0)
-false
+Checking if double matches double
+Some(1.0)
+Checking if double matches boolean
None
-true
+Checking if class java.lang.Double matches double
+Some(1.0)
+Checking if boolean matches boolean
Some(true)
-false
+Checking if boolean matches void
None
-true
+Checking if class java.lang.Boolean matches boolean
+Some(true)
+Checking if void matches void
Some(())
-false
+Checking if void matches byte
None
+Checking if class scala.runtime.BoxedUnit matches void
+Some(())