diff options
author | Grzegorz Kossakowski <grek@google.com> | 2009-08-27 11:29:56 -0700 |
---|---|---|
committer | Grzegorz Kossakowski <grek@google.com> | 2009-08-27 11:29:56 -0700 |
commit | 8653265e11020c9039a2d4b707546019ba46c555 (patch) | |
tree | d90630b34186bc951f9426577c14151c346a1c4f | |
parent | b106952081363e56bee7795bf6d9a8d59ae4774d (diff) | |
download | gimd-8653265e11020c9039a2d4b707546019ba46c555.tar.gz |
Rewritten ClassUtils to not use erasured type parameters in patterns.
Thanks to this change compiler won't emit warnings about erasured type
parameters used in pattern matching.
Signed-off-by: Grzegorz Kossakowski <grek@google.com>
-rw-r--r-- | src/main/scala/com/google/gimd/ClassUtils.scala | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/scala/com/google/gimd/ClassUtils.scala b/src/main/scala/com/google/gimd/ClassUtils.scala index cfb3ab8..6675987 100644 --- a/src/main/scala/com/google/gimd/ClassUtils.scala +++ b/src/main/scala/com/google/gimd/ClassUtils.scala @@ -30,15 +30,17 @@ object ClassUtils { else throw cannotGuessType(base) - private def beanTypeOf[Q,R](base: Class[Q], t: Type): Class[R] = - t match { + private def beanTypeOf[Q,R](base: Class[Q], t: Type): Class[R] = { + val c = t match { case t: ParameterizedType => t.getActualTypeArguments()(0) match { - case c: Class[R] => c + case c: Class[_] => c case wrongType => throw cannotGuessType(base) } case wrongType => throw cannotGuessType(base) } + c.asInstanceOf[Class[R]] + } private def cannotGuessType[Q](base: Class[Q]): IllegalStateException = new IllegalStateException("Cannot guess bean type wanted by " + base.getName) |