diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-04-23 16:04:56 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-04-23 17:54:50 +0200 |
commit | 0f0144c74088e396fc1440166bed5a7c6d5f44f4 (patch) | |
tree | fd7cc379f1926a3e6a0b94ccb22dd071384cdeb1 /src/compiler/scala/tools/nsc/interpreter/Power.scala | |
parent | 2b09d8caf5497c4e016a3e1179e5f7e842766176 (diff) | |
download | scala-0f0144c74088e396fc1440166bed5a7c6d5f44f4.tar.gz scala-0f0144c74088e396fc1440166bed5a7c6d5f44f4.tar.bz2 scala-0f0144c74088e396fc1440166bed5a7c6d5f44f4.zip |
migrates stdlib and compiler to tags
* all usages of ClassManifest and Manifest are replaced with tags
* all manifest tests are replaced with tag tests
Diffstat (limited to 'src/compiler/scala/tools/nsc/interpreter/Power.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/interpreter/Power.scala | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala index 2cb034f7ab..01ace0e984 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Power.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala @@ -42,10 +42,10 @@ Lost after 18/flatten { /** A class for methods to be injected into the intp in power mode. */ -class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: ReplValsImpl) { +class Power[ReplValsImpl <: ReplVals : TypeTag](val intp: IMain, replVals: ReplValsImpl) { import intp.{ beQuietDuring, typeOfExpression, interpret, parse } import intp.global._ - import definitions.{ manifestToType, manifestToSymbol, getClassIfDefined, getModuleIfDefined } + import definitions.{ compilerTypeFromTag, compilerSymbolFromTag, getClassIfDefined, getModuleIfDefined } abstract class SymSlurper { def isKeep(sym: Symbol): Boolean @@ -162,7 +162,7 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl } trait LowPriorityInternalInfo { - implicit def apply[T: Manifest] : InternalInfo[T] = new InternalInfo[T](None) + implicit def apply[T: TypeTag] : InternalInfo[T] = new InternalInfo[T](None) } object InternalInfo extends LowPriorityInternalInfo { } @@ -173,21 +173,21 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl * of the conveniences exist on that wrapper. */ trait LowPriorityInternalInfoWrapper { - implicit def apply[T: Manifest] : InternalInfoWrapper[T] = new InternalInfoWrapper[T](None) + implicit def apply[T: TypeTag] : InternalInfoWrapper[T] = new InternalInfoWrapper[T](None) } object InternalInfoWrapper extends LowPriorityInternalInfoWrapper { } - class InternalInfoWrapper[T: Manifest](value: Option[T] = None) { + class InternalInfoWrapper[T: TypeTag](value: Option[T] = None) { def ? : InternalInfo[T] = new InternalInfo[T](value) } /** Todos... - * translate manifest type arguments into applied types + * translate tag type arguments into applied types * customizable symbol filter (had to hardcode no-spec to reduce noise) */ - class InternalInfo[T: Manifest](value: Option[T] = None) { - private def newInfo[U: Manifest](value: U): InternalInfo[U] = new InternalInfo[U](Some(value)) + class InternalInfo[T: TypeTag](value: Option[T] = None) { + private def newInfo[U: TypeTag](value: U): InternalInfo[U] = new InternalInfo[U](Some(value)) private def isSpecialized(s: Symbol) = s.name.toString contains "$mc" private def isImplClass(s: Symbol) = s.name.toString endsWith "$class" @@ -198,8 +198,8 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl || s.isAnonOrRefinementClass || s.isAnonymousFunction ) - def symbol = manifestToSymbol(fullManifest) - def tpe = manifestToType(fullManifest) + def symbol = compilerSymbolFromTag(tag) + def tpe = compilerTypeFromTag(tag) def name = symbol.name def companion = symbol.companionSymbol def info = symbol.info @@ -226,8 +226,8 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl def pkgClasses = pkgMembers filter (s => s.isClass && s.isDefinedInPackage) def pkgSymbols = new PackageSlurper(pkgClass).slurp() filterNot excludeMember - def fullManifest = manifest[T] - def erasure = fullManifest.erasure + def tag = typeTag[T] + def erasure = tag.erasure def shortClass = erasure.getName split "[$.]" last def baseClasses = tpe.baseClasses @@ -236,9 +236,9 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl def ancestorDeclares(name: String) = ancestors filter (_.info member newTermName(name) ne NoSymbol) def baseTypes = tpe.baseTypeSeq.toList - def <:<[U: Manifest](other: U) = tpe <:< newInfo(other).tpe - def lub[U: Manifest](other: U) = intp.global.lub(List(tpe, newInfo(other).tpe)) - def glb[U: Manifest](other: U) = intp.global.glb(List(tpe, newInfo(other).tpe)) + def <:<[U: TypeTag](other: U) = tpe <:< newInfo(other).tpe + def lub[U: TypeTag](other: U) = intp.global.lub(List(tpe, newInfo(other).tpe)) + def glb[U: TypeTag](other: U) = intp.global.glb(List(tpe, newInfo(other).tpe)) override def toString = value match { case Some(x) => "%s (%s)".format(x, shortClass) @@ -366,7 +366,7 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl implicit lazy val powerSymbolOrdering: Ordering[Symbol] = Ordering[Name] on (_.name) implicit lazy val powerTypeOrdering: Ordering[Type] = Ordering[Symbol] on (_.typeSymbol) - implicit def replInternalInfo[T: Manifest](x: T): InternalInfoWrapper[T] = new InternalInfoWrapper[T](Some(x)) + implicit def replInternalInfo[T: TypeTag](x: T): InternalInfoWrapper[T] = new InternalInfoWrapper[T](Some(x)) implicit def replEnhancedStrings(s: String): RichReplString = new RichReplString(s) implicit def replMultiPrinting[T: Prettifier](xs: TraversableOnce[T]): MultiPrettifierClass[T] = new MultiPrettifierClass[T](xs.toSeq) @@ -381,10 +381,13 @@ class Power[ReplValsImpl <: ReplVals : Manifest](val intp: IMain, replVals: Repl } trait ReplUtilities { - def module[T: Manifest] = getModuleIfDefined(manifest[T].erasure.getName stripSuffix nme.MODULE_SUFFIX_STRING) - def clazz[T: Manifest] = getClassIfDefined(manifest[T].erasure.getName) - def info[T: Manifest] = InternalInfo[T] - def ?[T: Manifest] = InternalInfo[T] + // [Eugene to Paul] needs review! + // def module[T: TypeTag] = getModuleIfDefined(typeTag[T].erasure.getName stripSuffix nme.MODULE_SUFFIX_STRING) + // def clazz[T: TypeTag] = getClassIfDefined(typeTag[T].erasure.getName) + def module[T: TypeTag] = typeTag[T].sym.suchThat(_.isPackage) + def clazz[T: TypeTag] = typeTag[T].sym.suchThat(_.isClass) + def info[T: TypeTag] = InternalInfo[T] + def ?[T: TypeTag] = InternalInfo[T] def url(s: String) = { try new URL(s) catch { case _: MalformedURLException => |