Hi guys,
Is there a difference in the way intp.global behave as opposed to global object
I can get hold of in :power mode of the REPL?
While working on [:kind command][1]. I'm getting stuck with the same point @folone got stuck:
- [Adding :kind command to scala repl][2]
- [Getting type information inside scala repl via IMain][3]
1. For several reasons, I would like to use global instead of the runtime.universe.
2. In this discussion, let's assume I have the full name of the type.
I was able to port Adriaan's inferKind to trait Kinds, and get it work in :power mode:
scala> global.inferKind(NoPrefix)(intp.global.rootMirror.staticClass("scala.Option"))
final def getOrElse[B >: A](default: => B): B
final def orNull[A1 >: A](implicit ev: <:<[Null,A1]): A1
final def map[B](f: A => B): Option[B]
final def fold[B](ifEmpty: => B)(f: A => B): B
final def flatMap[B](f: A => Option[B]): Option[B]
def flatten[B](implicit ev: <:<[A,Option[B]]): Option[B]
final def filter(p: A => Boolean): Option[A]
final def filterNot(p: A => Boolean): Option[A]
final def nonEmpty: Boolean
final def withFilter(p: A => Boolean): Option.this.WithFilter
class WithFilter extends AnyRef
final def contains[A1 >: A](elem: A1): Boolean
final def exists(p: A => Boolean): Boolean
final def forall(p: A => Boolean): Boolean
final def foreach[U](f: A => U): Unit
final def collect[B](pf: PartialFunction[A,B]): Option[B]
final def orElse[B >: A](alternative: => Option[B]): Option[B]
def iterator: Iterator[A]
final def toRight[X](left: => X): Product with Serializable with scala.util.Either[X,A]
final def toLeft[X](right: => X): Product with Serializable with scala.util.Either[A,X]
class scala.reflect.internal.Types$PolyType
class scala.reflect.internal.Types$UniqueTypeBounds
res0: $r.global.Kind = F[+A]
I am doing some println of the Types to check what's going on. In the above I'm getting PolyType as expected.
:kind command does the same thing, but here's what I get.
scala> :kind scala.Option
final def getOrElse(default: Function0): Object
final def orNull(ev: less:<): Object
final def map(f: Function1): Option
final def fold(ifEmpty: Function0,f: Function1): Object
final def flatMap(f: Function1): Option
def flatten(ev: less:<): Option
final def filter(p: Function1): Option
final def filterNot(p: Function1): Option
final def nonEmpty(): Boolean
final def withFilter(p: Function1): Option#Option$WithFilter
final def contains(elem: Object): Boolean
final def exists(p: Function1): Boolean
final def forall(p: Function1): Boolean
final def foreach(f: Function1): Unit
final def collect(pf: PartialFunction): Option
final def orElse(alternative: Function0): Option
final def toRight(left: Function0): util.Either
final def toLeft(right: Function0): util.Either
class scala.reflect.internal.Types$ClassInfoType
Instead of PolyType, I get ClassInfoType. What am I doing wrong here?
The code that's converting the type symbol to Type is this:
abstract class InferKind {
def apply(tpe: Type, owner: Symbol): Kind
def apply(sym: Symbol): Kind = apply(sym.typeSignature, sym.owner)
}
-eugene