Permalink
Browse files

Merge pull request #1566 from densh/topic/asSeenFrom-example

Fixes example in Type.asSeenFrom
  • Loading branch information...
jsuereth committed Nov 4, 2012
2 parents e0b88a9 + 0360313 commit 3b798b039a24229cf9edb5f396de4dd9fe5980ee
Showing with 20 additions and 4 deletions.
  1. +20 −4 src/reflect/scala/reflect/api/Types.scala
@@ -171,10 +171,26 @@ trait Types { self: Universe =>
*
* Example:
* {{{
- * class D[T] { def m: T }
- * class C extends p.D[Int]
- * T.asSeenFrom(ThisType(C), D) // (where D is the owner of m)
- * = Int
+ * scala> import scala.reflect.runtime.universe._
+ * import scala.reflect.runtime.universe._
+ *
+ * scala> class D[T] { def m: T = ??? }
+ * defined class D
+ *
+ * scala> class C extends D[Int]
+ * defined class C
+ *
+ * scala> val D = typeOf[D[_]].typeSymbol.asClass
+ * D: reflect.runtime.universe.ClassSymbol = class D
+ *
+ * scala> val C = typeOf[C].typeSymbol.asClass
+ * C: reflect.runtime.universe.ClassSymbol = class C
+ *
+ * scala> val T = D.typeParams(0).asType.toType
+ * T: reflect.runtime.universe.Type = T
+ *
+ * scala> T.asSeenFrom(ThisType(C), D)
+ * res0: reflect.runtime.universe.Type = scala.Int
* }}}
*/
def asSeenFrom(pre: Type, clazz: Symbol): Type

0 comments on commit 3b798b0

Please sign in to comment.