summaryrefslogtreecommitdiff
path: root/test/files/run/spec-patmatch.scala
diff options
context:
space:
mode:
authorIulian Dragos <jaguarul@gmail.com>2010-02-28 21:09:06 +0000
committerIulian Dragos <jaguarul@gmail.com>2010-02-28 21:09:06 +0000
commitb94c6e0da6d33bc69f1419634128e2f401109b61 (patch)
tree89d1ed33a06fa92ae1282034927b188d4cf9398c /test/files/run/spec-patmatch.scala
parent9bfc0f0ac615b48b39b696dc1fb61ba07e5e8274 (diff)
downloadscala-b94c6e0da6d33bc69f1419634128e2f401109b61.tar.gz
scala-b94c6e0da6d33bc69f1419634128e2f401109b61.tar.bz2
scala-b94c6e0da6d33bc69f1419634128e2f401109b61.zip
Fixed specialized pattern matches.
specialized implementations.
Diffstat (limited to 'test/files/run/spec-patmatch.scala')
-rw-r--r--test/files/run/spec-patmatch.scala52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/files/run/spec-patmatch.scala b/test/files/run/spec-patmatch.scala
new file mode 100644
index 0000000000..92938836d8
--- /dev/null
+++ b/test/files/run/spec-patmatch.scala
@@ -0,0 +1,52 @@
+class Foo[@specialized A] {
+ def test(x: A) = println(x match {
+ case _: Boolean => "bool"
+ case _: Byte => "byte"
+ case _: Short => "short"
+ case _: Char => "char"
+ case i: Int => "int"
+ case l: Long => "long"
+ case d: Double => "double"
+ case e: Float => "float"
+ case _ => "default"
+ })
+}
+
+object Test {
+ def test[@specialized A] (x: A) = println(x match {
+ case _: Boolean => "bool"
+ case _: Byte => "byte"
+ case _: Short => "short"
+ case _: Char => "char"
+ case i: Int => "int"
+ case l: Long => "long"
+ case d: Double => "double"
+ case e: Float => "float"
+ case _ => "default"
+ })
+
+ def main(args: Array[String]) {
+ test(true)
+ test(42.toByte)
+ test(42.toShort)
+ test('b')
+ test(42)
+ test(42l)
+ test(42.0)
+ test(42.0f)
+ test(new Object)
+
+ println("object instantiations:")
+ (new Foo).test(true)
+ (new Foo).test(42.toByte)
+ (new Foo).test(42.toShort)
+ (new Foo).test('b')
+ (new Foo).test(42)
+ (new Foo).test(42l)
+ (new Foo).test(42.0)
+ (new Foo).test(42.0f)
+ (new Foo).test(new Object)
+
+ }
+
+}