diff options
author | Paul Phillips <paulp@improving.org> | 2011-06-13 20:51:57 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-06-13 20:51:57 +0000 |
commit | b6d1953b85bddc7ccd748fa8f8aa2b7d3eb1f194 (patch) | |
tree | b39ca3818b4803af062b561bc5342f8a7334e718 /test/files/run/primitive-sigs-2.scala | |
parent | 32d2b15d5db3e9e582632cc8f995dcc362751d6a (diff) | |
download | scala-b6d1953b85bddc7ccd748fa8f8aa2b7d3eb1f194.tar.gz scala-b6d1953b85bddc7ccd748fa8f8aa2b7d3eb1f194.tar.bz2 scala-b6d1953b85bddc7ccd748fa8f8aa2b7d3eb1f194.zip |
Test case for implicits which unwrap typeclasse...
Test case for implicits which unwrap typeclasses, something which must
really live on the edge given the multiple ways we've busted it lately.
Also some Array/signature and repl tests. No review.
Diffstat (limited to 'test/files/run/primitive-sigs-2.scala')
-rw-r--r-- | test/files/run/primitive-sigs-2.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/files/run/primitive-sigs-2.scala b/test/files/run/primitive-sigs-2.scala index a8876f7f60..b535e7c1fb 100644 --- a/test/files/run/primitive-sigs-2.scala +++ b/test/files/run/primitive-sigs-2.scala @@ -1,20 +1,39 @@ +import java.{ lang => jl } + trait T[A] { def f(): A } class C extends T[Char] { def f(): Char = 'a' } +class Arr { + def arr1(xs: Array[Int]): List[Int] = xs.toList + def arr2(xs: Array[jl.Character]): List[jl.Character] = xs.toList + def arr3(xss: Array[Array[Float]]): Array[Float] = xss map (_.sum) + // This gets a signature like + // public <T> java.lang.Object Arr.arr4(java.lang.Object[],scala.reflect.Manifest<T>) + // + // instead of the more appealing version from the past + // public <T> T[] Arr.arr4(T[][],scala.reflect.Manifest<T>) + // + // because java inflict's its reference-only generic-arrays on us. + // + def arr4[T: Manifest](xss: Array[Array[T]]): Array[T] = xss map (_.head) +} object Test { val c1: Class[_] = classOf[T[_]] val c2: Class[_] = classOf[C] + val c3: Class[_] = classOf[Arr] val c1m = c1.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) val c2m = c2.getMethods.toList filter (_.getName == "f") map (_.getGenericReturnType.toString) + val c3m = c3.getDeclaredMethods.toList map (_.toGenericString) def main(args: Array[String]): Unit = { println(c2.getGenericInterfaces.map(_.toString).sorted mkString " ") println(c1m ++ c2m sorted) println(new C f) + c3m foreach println } } |