diff options
author | Martin Odersky <odersky@gmail.com> | 2011-07-22 09:24:31 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2011-07-22 09:24:31 +0000 |
commit | fb2e30e4728e6378136f2858da49a1b87ed7c60d (patch) | |
tree | bab9e937b01fe9f7914996320a340b074fa3c910 /src | |
parent | 654c9ff6e67f2c7c49b5a97dba98028406f6c83a (diff) | |
download | scala-fb2e30e4728e6378136f2858da49a1b87ed7c60d.tar.gz scala-fb2e30e4728e6378136f2858da49a1b87ed7c60d.tar.bz2 scala-fb2e30e4728e6378136f2858da49a1b87ed7c60d.zip |
Small fix to mirrors in treatment of primitive ...
Small fix to mirrors in treatment of primitive types. No review.
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/reflect/api/Mirror.scala | 4 | ||||
-rw-r--r-- | src/compiler/scala/reflect/runtime/Mirror.scala | 6 | ||||
-rw-r--r-- | src/compiler/scala/reflect/runtime/ScalaToJava.scala | 1 |
3 files changed, 7 insertions, 4 deletions
diff --git a/src/compiler/scala/reflect/api/Mirror.scala b/src/compiler/scala/reflect/api/Mirror.scala index bd111fb3b6..b6a9304617 100644 --- a/src/compiler/scala/reflect/api/Mirror.scala +++ b/src/compiler/scala/reflect/api/Mirror.scala @@ -18,7 +18,7 @@ trait Mirror extends Universe { * @param The object from which the class is returned * @throws ? */ - def getClass(obj: Any): Symbol + def getClass(obj: AnyRef): Symbol /** The Scala type corresponding to the runtime type of given object. * If the underlying class is parameterized, this will be an existential type, @@ -27,7 +27,7 @@ trait Mirror extends Universe { * @param The object from which the type is returned * @throws ? */ - def getType(obj: Any): Type + def getType(obj: AnyRef): Type def getValue(receiver: AnyRef, field: Symbol): Any def setValue(receiver: AnyRef, field: Symbol, value: Any): Unit diff --git a/src/compiler/scala/reflect/runtime/Mirror.scala b/src/compiler/scala/reflect/runtime/Mirror.scala index 9d98090f00..18283f3898 100644 --- a/src/compiler/scala/reflect/runtime/Mirror.scala +++ b/src/compiler/scala/reflect/runtime/Mirror.scala @@ -8,8 +8,10 @@ import internal.{SomePhase, NoPhase, Phase, TreeGen} class Mirror extends Universe with api.Mirror { def classWithName(name: String): Symbol = classToScala(java.lang.Class.forName(name)) - def getClass(obj: Any): Symbol = classToScala(obj.asInstanceOf[AnyRef].getClass) // To do: Not sure what to do with primitive classes here - def getType(obj: Any): Type = typeToScala(obj.asInstanceOf[AnyRef].getClass) + def getClass(obj: AnyRef): Symbol = classToScala(obj.getClass) + def getType(obj: AnyRef): Type = typeToScala(obj.getClass) + // to do add getClass/getType for instances of primitive types, probably like this: + // def getClass[T <: AnyVal : Manifest](x: T): Symbol = manifest[T].getClass def getValue(receiver: AnyRef, field: Symbol): Any = fieldToJava(field).get(receiver) def setValue(receiver: AnyRef, field: Symbol, value: Any): Unit = fieldToJava(field).set(receiver, value) diff --git a/src/compiler/scala/reflect/runtime/ScalaToJava.scala b/src/compiler/scala/reflect/runtime/ScalaToJava.scala index e9b5b96bc8..b3f898e709 100644 --- a/src/compiler/scala/reflect/runtime/ScalaToJava.scala +++ b/src/compiler/scala/reflect/runtime/ScalaToJava.scala @@ -26,6 +26,7 @@ trait ScalaToJava extends ConversionUtil { self: Universe => */ def classToJava(clazz: Symbol): jClass[_] = classCache.toJava(clazz) { def noClass = throw new NoClassDefFoundError("no Java class corresponding to "+clazz+" found") + println("classToJava "+clazz+" "+clazz.owner+" "+clazz.owner.isPackageClass) if (clazz.owner.isPackageClass) jClass.forName(clazz.fullName) else if (clazz.owner.isClass) |