diff options
author | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2009-04-29 15:19:22 +0000 |
---|---|---|
committer | Gilles Dubochet <gilles.dubochet@epfl.ch> | 2009-04-29 15:19:22 +0000 |
commit | a62eceab93925296a9c21c6d8ca7978e0b669aa4 (patch) | |
tree | d7cb673d712188975d35037b1c1304f2db297118 /src | |
parent | 0a80c26324dfd538340b802457bfafda6cf42479 (diff) | |
download | scala-a62eceab93925296a9c21c6d8ca7978e0b669aa4.tar.gz scala-a62eceab93925296a9c21c6d8ca7978e0b669aa4.tar.bz2 scala-a62eceab93925296a9c21c6d8ca7978e0b669aa4.zip |
Further fix to r17585: less hacky implementatio...
Further fix to r17585: less hacky implementation of "extended" subtyping
for manifests.
Diffstat (limited to 'src')
-rw-r--r-- | src/library/scala/reflect/Manifest.scala | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index 826211c8ab..94283b6e19 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -60,6 +60,8 @@ trait Manifest[T] extends OptManifest[T] { case _ => false } + private[reflect] def typeArguments: Option[List[Manifest[_]]] = None + } /** <p> @@ -98,19 +100,18 @@ object Manifest { def classType[T](clazz: Predef.Class[_], args: Manifest[_]*): Manifest[T] = new (Manifest[T] @serializable) { val erasure = clazz - val typeArguments: Seq[Manifest[_]] = args + private[reflect] override val typeArguments = Some(args.toList) override def <:<(that: Manifest[_]): Boolean = { - try { - val meth = that.getClass().getMethod("typeArguments", null) - val args1 = meth.invoke(that, null).asInstanceOf[Array[Manifest[_]]] - super.<:<(that) && args.equalsWith(args1)((x, y) => x <:< y) - } catch { - case _ => super.<:<(that) + that.typeArguments match { + case Some(thatArgs) => + super.<:<(that) && args.equalsWith(thatArgs) { (x, y) => x <:< y } + case None => + false } } override lazy val toString = (if (erasure.isArray) "Array" else erasure.getName) + - typeArguments.mkString("[", ", ", "]") + args.toList.mkString("[", ", ", "]") } /** Manifest for the class type `prefix # clazz'. */ @@ -124,7 +125,7 @@ object Manifest { def classType[T](prefix: Manifest[_], clazz: Predef.Class[_], args: Manifest[_]*): Manifest[T] = new (Manifest[T] @serializable) { val erasure = clazz - val typeArguments: Seq[Manifest[_]] = args + private[reflect] override val typeArguments = Some(args.toList) override lazy val toString = prefix.toString + "#" + erasure.getName + typeArguments.mkString("[", ", ", "]") } @@ -142,7 +143,7 @@ object Manifest { def abstractType[T](prefix: Manifest[_], name: String, upperBound: Manifest[_], args: Manifest[_]*): Manifest[T] = new (Manifest[T] @serializable) { lazy val erasure = upperBound.erasure - val typeArguments: Seq[Manifest[_]] = args + private[reflect] override val typeArguments = Some(args.toList) override lazy val toString = prefix.toString + "#" + name + typeArguments.mkString("[", ", ", "]") } |