diff options
-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) |