Replaced various now-unnecessary casts with straight getClass

calls.  Closes SI-4780, no review.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@25575 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2011-08-27 18:02:01 +00:00
parent 1ca8734604
commit e82fd5e80e
7 changed files with 7 additions and 7 deletions

View File

@ -6069,7 +6069,7 @@ A type's typeSymbol should never be inspected directly.
/** Perform operation `p` on arguments `tp1`, `arg2` and print trace of computation. */
private def explain[T](op: String, p: (Type, T) => Boolean, tp1: Type, arg2: T): Boolean = {
Console.println(indent + tp1 + " " + op + " " + arg2 + "?" /* + "("+tp1.getClass+","+arg2.asInstanceOf[AnyRef].getClass+")"*/)
Console.println(indent + tp1 + " " + op + " " + arg2 + "?" /* + "("+tp1.getClass+","+arg2.getClass+")"*/)
indent = indent + " "
val result = p(tp1, arg2)
indent = indent dropRight 2

View File

@ -56,7 +56,7 @@ trait TypeStrings {
)
}
def scalaName(m: ClassManifest[_]): String = scalaName(m.erasure)
def anyClass(x: Any): JClass = if (x == null) null else x.asInstanceOf[AnyRef].getClass
def anyClass(x: Any): JClass = if (x == null) null else x.getClass
private def brackets(tps: String*): String =
if (tps.isEmpty) ""

View File

@ -246,7 +246,7 @@ object Pickler {
p.tryPickle(wr, x) || qq.tryPickle(wr, x)
def pickle(wr: Writer, x: T) =
require(tryPickle(wr, x),
"no pickler found for "+x+" of class "+x.asInstanceOf[AnyRef].getClass.getName)
"no pickler found for "+x+" of class "+x.getClass.getName)
def unpickle(rd: Lexer) = p.unpickle(rd) orElse qq.unpickle(rd)
}

View File

@ -134,7 +134,7 @@ object ScalaClassLoader {
}
/** Finding what jar a clazz or instance came from */
def origin(x: Any): Option[URL] = originOfClass(x.asInstanceOf[AnyRef].getClass)
def origin(x: Any): Option[URL] = originOfClass(x.getClass)
def originOfClass(x: Class[_]): Option[URL] =
Option(x.getProtectionDomain.getCodeSource) flatMap (x => Option(x.getLocation))
}

View File

@ -25,7 +25,7 @@ final class MatchError(obj: Any) extends RuntimeException {
*/
private lazy val objString =
if (obj == null) "null"
else obj.toString() + " (of class " + obj.asInstanceOf[AnyRef].getClass.getName + ")"
else obj.toString() + " (of class " + obj.getClass.getName + ")"
override def getMessage() = objString
}

View File

@ -627,7 +627,7 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr]
* simple name of the collection class $coll.
*/
def stringPrefix : String = {
var string = repr.asInstanceOf[AnyRef].getClass.getName
var string = repr.getClass.getName
val idx1 = string.lastIndexOf('.' : Int)
if (idx1 != -1) string = string.substring(idx1 + 1)
val idx2 = string.indexOf('$')

View File

@ -25,7 +25,7 @@ import java.lang.reflect.{ Modifier, Method => JMethod }
object ScalaRunTime {
def isArray(x: AnyRef): Boolean = isArray(x, 1)
def isArray(x: Any, atLevel: Int): Boolean =
x != null && isArrayClass(x.asInstanceOf[AnyRef].getClass, atLevel)
x != null && isArrayClass(x.getClass, atLevel)
private def isArrayClass(clazz: Class[_], atLevel: Int): Boolean =
clazz.isArray && (atLevel == 1 || isArrayClass(clazz.getComponentType, atLevel - 1))