Note that there are some explanatory texts on larger screens.

plurals
  1. POType equality in the Scala 2.10 Reflection API
    text
    copied!<p>I'm running into a weird issue with reflection in <a href="http://www.scala-lang.org/node/12702" rel="noreferrer">Scala 2.10.0 Milestone 4</a> that I can't wrap my head around. First for the stuff that works the way I'd expect:</p> <pre><code>scala&gt; import scala.reflect.runtime.universe._ import scala.reflect.runtime.universe._ scala&gt; trait A[X]; trait B[Y] extends A[Y] defined trait A defined trait B scala&gt; typeOf[B[String]].parents res0: List[reflect.runtime.universe.Type] = List(java.lang.Object, A[String]) scala&gt; typeOf[B[String]].parents contains typeOf[A[String]] res1: Boolean = true </code></pre> <p>Similarly (in the same session):</p> <pre><code>scala&gt; trait D; trait E extends A[D] defined trait D defined trait E scala&gt; typeOf[E].parents res2: List[reflect.runtime.universe.Type] = List(java.lang.Object, A[D]) scala&gt; typeOf[E].parents contains typeOf[A[D]] res3: Boolean = true </code></pre> <p>No surprises here: I can ask for a type's parents and get exactly what I expect. Now I essentially combine the two examples above:</p> <pre><code>scala&gt; trait F extends A[String] defined trait F scala&gt; typeOf[F].parents res4: List[reflect.runtime.universe.Type] = List(java.lang.Object, A[String]) scala&gt; typeOf[F].parents contains typeOf[A[String]] res5: Boolean = false </code></pre> <p>I don't understand how this could be false. The same thing happens if I have <code>F</code> extend <code>A[Seq[D]]</code>, <code>A[Int]</code>, etc. What's the generalization I'm missing that would make this behavior make sense?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload