diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-06-06 09:43:05 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-06-08 15:31:45 +0200 |
commit | 252a44864786b6832b9da4c29d1ac9aad48c4291 (patch) | |
tree | aef048d8a210d38f116b8875d99e3c13c703d685 /src/compiler | |
parent | 6bb5975289c5b11cb8c88dd4629286956b5d3d27 (diff) | |
download | scala-252a44864786b6832b9da4c29d1ac9aad48c4291.tar.gz scala-252a44864786b6832b9da4c29d1ac9aad48c4291.tar.bz2 scala-252a44864786b6832b9da4c29d1ac9aad48c4291.zip |
ClassTag.erasure => ClassTag.runtimeClass
This change is made to be consistent with JavaMirrors.
And, in my opinion, a technology-neutral term is better here.
Diffstat (limited to 'src/compiler')
14 files changed, 28 insertions, 28 deletions
diff --git a/src/compiler/scala/reflect/api/TagInterop.scala b/src/compiler/scala/reflect/api/TagInterop.scala index a5b303bb37..e10b89d1c6 100644 --- a/src/compiler/scala/reflect/api/TagInterop.scala +++ b/src/compiler/scala/reflect/api/TagInterop.scala @@ -15,8 +15,8 @@ trait TagInterop { self: JavaUniverse => // [Eugene++] implement more sophisticated logic // Martin said it'd be okay to simply copypaste `Implicits.manifestOfType` val mirror = mirror0.asInstanceOf[Mirror] - val erasure = mirror.runtimeClass(tag.in(mirror).tpe) - Manifest.classType(erasure).asInstanceOf[Manifest[T]] + val runtimeClass = mirror.runtimeClass(tag.in(mirror).tpe) + Manifest.classType(runtimeClass).asInstanceOf[Manifest[T]] } override def manifestToConcreteTypeTag[T](mirror0: Any, manifest: Manifest[T]): base.Universe # ConcreteTypeTag[T] = diff --git a/src/compiler/scala/reflect/internal/Mirrors.scala b/src/compiler/scala/reflect/internal/Mirrors.scala index fa411bc935..e3680b14d5 100644 --- a/src/compiler/scala/reflect/internal/Mirrors.scala +++ b/src/compiler/scala/reflect/internal/Mirrors.scala @@ -103,7 +103,7 @@ trait Mirrors extends api.Mirrors { if (clazz.isArray) "Array[" + erasureString(clazz.getComponentType) + "]" else clazz.getName } - erasureString(classTag[T].erasure) + erasureString(classTag[T].runtimeClass) } def requiredClass[T: ClassTag] : ClassSymbol = diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index e166994b98..07fbe6f049 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -651,7 +651,6 @@ trait StdNames { val equalsNumNum : NameType = "equalsNumNum" val equalsNumObject : NameType = "equalsNumObject" val equals_ : NameType = if (forMSIL) "Equals" else "equals" - val erasure: NameType = "erasure" val error: NameType = "error" val eval: NameType = "eval" val ex: NameType = "ex" @@ -727,6 +726,7 @@ trait StdNames { val rootMirror : NameType = "rootMirror" val runOrElse: NameType = "runOrElse" val runtime: NameType = "runtime" + val runtimeClass: NameType = "runtimeClass" val runtimeMirror: NameType = "runtimeMirror" val sameElements: NameType = "sameElements" val scala_ : NameType = "scala" diff --git a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala b/src/compiler/scala/reflect/makro/runtime/Reifiers.scala index fd683fd229..95e031ebc8 100644 --- a/src/compiler/scala/reflect/makro/runtime/Reifiers.scala +++ b/src/compiler/scala/reflect/makro/runtime/Reifiers.scala @@ -20,8 +20,8 @@ trait Reifiers { def reifyType(prefix: Tree, tpe: Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): Tree = scala.reflect.reify.`package`.reifyType(mirror)(callsiteTyper, prefix, tpe, dontSpliceAtTopLevel, concrete) - def reifyErasure(tpe: Type, concrete: Boolean = true): Tree = - scala.reflect.reify.`package`.reifyErasure(mirror)(callsiteTyper, tpe, concrete) + def reifyRuntimeClass(tpe: Type, concrete: Boolean = true): Tree = + scala.reflect.reify.`package`.reifyRuntimeClass(mirror)(callsiteTyper, tpe, concrete) def unreifyTree(tree: Tree): Tree = Select(tree, definitions.ExprSplice) diff --git a/src/compiler/scala/reflect/reify/Reifier.scala b/src/compiler/scala/reflect/reify/Reifier.scala index fea825358e..41b45741ba 100644 --- a/src/compiler/scala/reflect/reify/Reifier.scala +++ b/src/compiler/scala/reflect/reify/Reifier.scala @@ -78,7 +78,7 @@ abstract class Reifier extends Phases val tagModule = if (reificationIsConcrete) ConcreteTypeTagModule else TypeTagModule val tagCtor = TypeApply(Select(Ident(nme.MIRROR_SHORT), tagModule.name), List(TypeTree(taggedType))) val exprCtor = TypeApply(Select(Ident(nme.MIRROR_SHORT), ExprModule.name), List(TypeTree(taggedType))) - val tagArgs = List(reify(taggedType), reifyErasure(mirror)(typer, taggedType, concrete = false)) + val tagArgs = List(reify(taggedType), reifyRuntimeClass(mirror)(typer, taggedType, concrete = false)) Apply(Apply(exprCtor, List(rtree)), List(Apply(tagCtor, tagArgs))) case tpe: Type => @@ -89,7 +89,7 @@ abstract class Reifier extends Phases val taggedType = tpe val tagModule = if (reificationIsConcrete) ConcreteTypeTagModule else TypeTagModule val ctor = TypeApply(Select(Ident(nme.MIRROR_SHORT), tagModule.name), List(TypeTree(taggedType))) - val args = List(rtree, reifyErasure(mirror)(typer, taggedType, concrete = false)) + val args = List(rtree, reifyRuntimeClass(mirror)(typer, taggedType, concrete = false)) Apply(ctor, args) case _ => diff --git a/src/compiler/scala/reflect/reify/Taggers.scala b/src/compiler/scala/reflect/reify/Taggers.scala index d0ef6fcdbf..26b8b1efde 100644 --- a/src/compiler/scala/reflect/reify/Taggers.scala +++ b/src/compiler/scala/reflect/reify/Taggers.scala @@ -32,9 +32,9 @@ abstract class Taggers { def materializeClassTag(prefix: Tree, tpe: Type): Tree = materializeTag(prefix, tpe, ClassTagModule, { - val erasure = c.reifyErasure(tpe, concrete = true) + val runtimeClass = c.reifyRuntimeClass(tpe, concrete = true) val factory = TypeApply(Select(Ident(ClassTagModule), "apply"), List(TypeTree(tpe))) - Apply(factory, List(erasure)) + Apply(factory, List(runtimeClass)) }) def materializeTypeTag(prefix: Tree, tpe: Type, concrete: Boolean): Tree = { diff --git a/src/compiler/scala/reflect/reify/package.scala b/src/compiler/scala/reflect/reify/package.scala index a096e2e93b..35b3d9bf38 100644 --- a/src/compiler/scala/reflect/reify/package.scala +++ b/src/compiler/scala/reflect/reify/package.scala @@ -28,7 +28,7 @@ package object reify { def reifyType(global: Global)(typer: global.analyzer.Typer, prefix: global.Tree, tpe: global.Type, dontSpliceAtTopLevel: Boolean = false, concrete: Boolean = false): global.Tree = mkReifier(global)(typer, prefix, tpe, dontSpliceAtTopLevel, concrete).reified.asInstanceOf[global.Tree] - def reifyErasure(global: Global)(typer0: global.analyzer.Typer, tpe: global.Type, concrete: Boolean = true): global.Tree = { + def reifyRuntimeClass(global: Global)(typer0: global.analyzer.Typer, tpe: global.Type, concrete: Boolean = true): global.Tree = { import global._ import definitions._ import analyzer.enclosingMacroPosition @@ -39,14 +39,14 @@ package object reify { inScope match { case (success, _) if !success.isEmpty => - Select(success, nme.erasure) + Select(success, nme.runtimeClass) case (_, success) if !success.isEmpty => gen.mkMethodCall(arrayElementClassMethod, List(success)) case _ => tpe.normalize match { case TypeRef(_, ArrayClass, componentTpe :: Nil) => - val componentErasure = reifyErasure(global)(typer0, componentTpe, concrete) - gen.mkMethodCall(arrayClassMethod, List(componentErasure)) + val componentRuntimeClass = reifyRuntimeClass(global)(typer0, componentTpe, concrete) + gen.mkMethodCall(arrayClassMethod, List(componentRuntimeClass)) case _ => if (tpe.isSpliceable && concrete) throw new ReificationError(enclosingMacroPosition, "tpe %s is an unresolved spliceable type".format(tpe)) diff --git a/src/compiler/scala/tools/nsc/interpreter/IMain.scala b/src/compiler/scala/tools/nsc/interpreter/IMain.scala index 94f51b78ed..0be8579d30 100644 --- a/src/compiler/scala/tools/nsc/interpreter/IMain.scala +++ b/src/compiler/scala/tools/nsc/interpreter/IMain.scala @@ -1120,9 +1120,9 @@ class IMain(initialSettings: Settings, protected val out: JPrintWriter) extends findName(termname) orElse getModuleIfDefined(termname) } // [Eugene to Paul] possibly you could make use of TypeTags here - def types[T: ClassTag] : Symbol = types(classTag[T].erasure.getName) - def terms[T: ClassTag] : Symbol = terms(classTag[T].erasure.getName) - def apply[T: ClassTag] : Symbol = apply(classTag[T].erasure.getName) + def types[T: ClassTag] : Symbol = types(classTag[T].runtimeClass.getName) + def terms[T: ClassTag] : Symbol = terms(classTag[T].runtimeClass.getName) + def apply[T: ClassTag] : Symbol = apply(classTag[T].runtimeClass.getName) def classSymbols = allDefSymbols collect { case x: ClassSymbol => x } def methodSymbols = allDefSymbols collect { case x: MethodSymbol => x } diff --git a/src/compiler/scala/tools/nsc/interpreter/Power.scala b/src/compiler/scala/tools/nsc/interpreter/Power.scala index a0687c824b..ee69c83f4d 100644 --- a/src/compiler/scala/tools/nsc/interpreter/Power.scala +++ b/src/compiler/scala/tools/nsc/interpreter/Power.scala @@ -188,7 +188,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re * translate tag type arguments into applied types * customizable symbol filter (had to hardcode no-spec to reduce noise) */ - class InternalInfo[T](value: Option[T] = None)(implicit typeEvidence: ru.TypeTag[T], erasureEvidence: ClassTag[T]) { + class InternalInfo[T](value: Option[T] = None)(implicit typeEvidence: ru.TypeTag[T], runtimeClassEvidence: ClassTag[T]) { private def newInfo[U: ru.TypeTag : ClassTag](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" @@ -229,8 +229,8 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re def pkgSymbols = new PackageSlurper(pkgClass).slurp() filterNot excludeMember def tag = typeEvidence - def erasure = erasureEvidence.erasure - def shortClass = erasure.getName split "[$.]" last + def runtimeClass = runtimeClassEvidence.runtimeClass + def shortClass = runtimeClass.getName split "[$.]" last def baseClasses = tpe.baseClasses def baseClassDecls = mapFrom(baseClasses)(_.info.decls.toList.sortBy(_.name)) @@ -244,7 +244,7 @@ class Power[ReplValsImpl <: ReplVals : ru.TypeTag: ClassTag](val intp: IMain, re override def toString = value match { case Some(x) => "%s (%s)".format(x, shortClass) - case _ => erasure.getName + case _ => runtimeClass.getName } } diff --git a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala index cea9b9e112..c5888129f5 100644 --- a/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala +++ b/src/compiler/scala/tools/nsc/interpreter/TypeStrings.scala @@ -192,7 +192,7 @@ trait TypeStrings { else enclClass.getName + "." + (name stripPrefix enclPre) ) } - def scalaName(ct: ClassTag[_]): String = scalaName(ct.erasure) + def scalaName(ct: ClassTag[_]): String = scalaName(ct.runtimeClass) def anyClass(x: Any): JClass = if (x == null) null else x.getClass private def brackets(tps: String*): String = @@ -229,7 +229,7 @@ trait TypeStrings { def fromTypedValue[T: ru.TypeTag : ClassTag](x: T): String = fromTag[T] def fromValue(value: Any): String = if (value == null) "Null" else fromClazz(anyClass(value)) def fromClazz(clazz: JClass): String = scalaName(clazz) + tparamString(clazz) - def fromTag[T: ru.TypeTag : ClassTag] : String = scalaName(classTag[T].erasure) + tparamString[T] + def fromTag[T: ru.TypeTag : ClassTag] : String = scalaName(classTag[T].runtimeClass) + tparamString[T] /** Reducing fully qualified noise for some common packages. */ diff --git a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala index c4dd9a2a36..2e4aa270bc 100644 --- a/src/compiler/scala/tools/nsc/settings/MutableSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/MutableSettings.scala @@ -184,7 +184,7 @@ class MutableSettings(val errorFn: String => Unit) * and `boot.class.path`. These resources should contain the application * and boot classpaths in the same form as would be passed on the command line.*/ def embeddedDefaults[T: ClassTag]: Unit = - embeddedDefaults(classTag[T].erasure.getClassLoader) + embeddedDefaults(classTag[T].runtimeClass.getClassLoader) /** Initializes these settings for embedded use by a class from the given class loader. * The class loader for `T` should provide resources `app.class.path` diff --git a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala index d26f3247da..776d61af2f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala +++ b/src/compiler/scala/tools/nsc/typechecker/MethodSynthesis.scala @@ -45,7 +45,7 @@ trait MethodSynthesis { } def companionType[T](implicit ct: CT[T]) = - rootMirror.getRequiredModule(ct.erasure.getName).tpe + rootMirror.getRequiredModule(ct.runtimeClass.getName).tpe // Use these like `applyType[List, Int]` or `applyType[Map, Int, String]` def applyType[CC](implicit t1: CTT[CC]): Type = diff --git a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala index 1db6b4a170..0f8c0755e0 100644 --- a/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala +++ b/src/compiler/scala/tools/nsc/util/ScalaClassLoader.scala @@ -46,7 +46,7 @@ trait ScalaClassLoader extends JClassLoader { tryToInitializeClass[AnyRef](path) map (_.newInstance()) orNull def constructorsOf[T <: AnyRef : ClassTag]: List[Constructor[T]] = - classTag[T].erasure.getConstructors.toList map (_.asInstanceOf[Constructor[T]]) + classTag[T].runtimeClass.getConstructors.toList map (_.asInstanceOf[Constructor[T]]) /** The actual bytes for a class file, or an empty array if it can't be found. */ def classBytes(className: String): Array[Byte] = classAsStream(className) match { @@ -102,7 +102,7 @@ object ScalaClassLoader { def bootLoader = apply(null) def contextChain = loaderChain(contextLoader) - def pathToErasure[T: ClassTag] = pathToClass(classTag[T].erasure) + def pathToErasure[T: ClassTag] = pathToClass(classTag[T].runtimeClass) def pathToClass(clazz: Class[_]) = clazz.getName.replace('.', JFile.separatorChar) + ".class" def locate[T: ClassTag] = contextLoader getResource pathToErasure[T] diff --git a/src/compiler/scala/tools/reflect/StdTags.scala b/src/compiler/scala/tools/reflect/StdTags.scala index 914219c04e..f01e476273 100644 --- a/src/compiler/scala/tools/reflect/StdTags.scala +++ b/src/compiler/scala/tools/reflect/StdTags.scala @@ -29,7 +29,7 @@ object StdTags { ru.runtimeMirror(ourClassloader), new TypeCreator { def apply[U <: BaseUniverse with Singleton](m: MirrorOf[U]): U # Type = - m.staticClass(classTag[T].erasure.getName).asTypeConstructor.asInstanceOf[U # Type] + m.staticClass(classTag[T].runtimeClass.getName).asTypeConstructor.asInstanceOf[U # Type] }) lazy val tagOfInt = ru.TypeTag.Int lazy val tagOfFile = tagOfStaticClass[scala.tools.nsc.io.File] |