On Sun, Oct 11, 2009 at 1:41 AM, Daniel Mahler <
dmahler@...> wrote:
> I am having trouble getting Maifests to behave.
> I know about erasure issues, but I do not think erasure is involved here.
> Could somebody please explain what is going on:
>
> Welcome to Scala version 2.8.0.r18965-b20091008021654 (OpenJDK 64-Bit
> Server VM, Java 1.6.0_0).
> Type in expressions to have them evaluated.
> Type :help for more information.
>
> scala> import scala.reflect.Manifest
> import scala.reflect.Manifest
>
> scala> def manifestOf[T](implicit m : Manifest[T]) = m
> manifestOf: [T](implicit m: scala.reflect.Manifest[T])scala.reflect.Manifest[T]
>
> scala> manifestOf[java.lang.Integer] <:< manifestOf[Any]
> res0: Boolean = true
>
> scala> manifestOf[Int] <:< manifestOf[Any]
> res1: Boolean = false
>
> // Huh!?!
>
Manifests are not done yet, so any experiments you do with them now
are not that cinclusive. In particular <:< still has cases missing.
> scala> def DescriptorsOf[T](implicit m: Manifest[T]) = {
> | if (m <:< manifestOf[Predef.Pair[_,_]])
> | m + " is Pair"
> | else
> | if (m <:< manifestOf[java.lang.Integer])
> | m + " is Pair"
> | else
> | if (m <:< manifestOf[Iterable[_]])
> | m + "is Iterable"
> | else
> | if (m <:< manifestOf[scala.collection.Iterable[_]])
> | m + "is Iterable"
> | else
> | m + "is ???"
> | }
> <console>:16: error: could not find implicit value for parameter m:
> scala.reflect.Manifest[Iterable[_]]
> if (m <:< manifestOf[scala.collection.Iterable[_]])
> ^
>
> Note that it only complains about the qualified Iterable test:
>
Interesting. I'll have a look at it. -- Martin