diff options
-rw-r--r-- | src/reflect/scala/reflect/runtime/JavaMirrors.scala | 8 | ||||
-rw-r--r-- | test/files/run/reflection-java-crtp.check | 25 | ||||
-rw-r--r-- | test/files/run/reflection-java-crtp.jar.desired.sha1 | 1 | ||||
-rw-r--r-- | test/files/run/reflection-java-crtp.scala | 21 |
4 files changed, 50 insertions, 5 deletions
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index 47978821a3..08f3922758 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -659,7 +659,6 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { thisUnive } override def complete(sym: Symbol): Unit = { - if (jclazz.isEnum) throw new ScalaReflectionException("implementation restriction: Java enums are not supported") load(sym) completeRest() } @@ -1024,10 +1023,9 @@ trait JavaMirrors extends internal.SymbolTable with api.JavaUniverse { thisUnive rawToExistential(typeRef(clazz.owner.thisType, clazz, List())) } case japplied: ParameterizedType => - val (pre, sym) = typeToScala(japplied.getRawType) match { - case ExistentialType(tparams, TypeRef(pre, sym, _)) => (pre, sym) - case TypeRef(pre, sym, _) => (pre, sym) - } + // http://stackoverflow.com/questions/5767122/parameterizedtype-getrawtype-returns-j-l-r-type-not-class + val sym = classToScala(japplied.getRawType.asInstanceOf[jClass[_]]) + val pre = sym.owner.thisType val args0 = japplied.getActualTypeArguments val (args, bounds) = targsToScala(pre.typeSymbol, args0.toList) ExistentialType(bounds, typeRef(pre, sym, args)) diff --git a/test/files/run/reflection-java-crtp.check b/test/files/run/reflection-java-crtp.check new file mode 100644 index 0000000000..0f30b453c0 --- /dev/null +++ b/test/files/run/reflection-java-crtp.check @@ -0,0 +1,25 @@ +Type in expressions to have them evaluated.
+Type :help for more information.
+
+scala>
+
+scala> import scala.reflect.runtime.universe._
+import scala.reflect.runtime.universe._
+
+scala> val enum = typeOf[SimpleEnumeration].baseClasses(1).asClass
+enum: reflect.runtime.universe.ClassSymbol = class Enum
+
+scala> // make sure that the E's in Enum<E extends Enum<E>> are represented by the same symbol
+
+scala> val e1 = enum.typeParams(0).asType
+e1: reflect.runtime.universe.TypeSymbol = type E
+
+scala> val TypeBounds(_, ExistentialType(_, TypeRef(_, _, List(TypeRef(_, e2: TypeSymbol, _))))) = e1.typeSignature
+e2: reflect.runtime.universe.TypeSymbol = type E
+
+scala> println(e1 eq e2)
+true
+
+scala>
+
+scala>
diff --git a/test/files/run/reflection-java-crtp.jar.desired.sha1 b/test/files/run/reflection-java-crtp.jar.desired.sha1 new file mode 100644 index 0000000000..a29c297008 --- /dev/null +++ b/test/files/run/reflection-java-crtp.jar.desired.sha1 @@ -0,0 +1 @@ +3d7787300f0351f101f448ee20f05a0a512f064f ?reflection-java-crtp.jar diff --git a/test/files/run/reflection-java-crtp.scala b/test/files/run/reflection-java-crtp.scala new file mode 100644 index 0000000000..87c7972d87 --- /dev/null +++ b/test/files/run/reflection-java-crtp.scala @@ -0,0 +1,21 @@ +import scala.tools.partest._ +import scala.tools.nsc.Settings + +object Test extends ReplTest { + def code = """ + import scala.reflect.runtime.universe._ + val enum = typeOf[SimpleEnumeration].baseClasses(1).asClass + // make sure that the E's in Enum<E extends Enum<E>> are represented by the same symbol + val e1 = enum.typeParams(0).asType + val TypeBounds(_, ExistentialType(_, TypeRef(_, _, List(TypeRef(_, e2: TypeSymbol, _))))) = e1.typeSignature + println(e1 eq e2) + """ + + override def transformSettings(settings: Settings): Settings = { + val thisFile = testPath.jfile.getAbsolutePath + val javaCompiledAnnotationsJar = (thisFile stripSuffix "scala") + "jar" + val classpath = List(sys.props("partest.lib"), sys.props("partest.reflect"), sys.props("partest.comp"), javaCompiledAnnotationsJar) mkString sys.props("path.separator") + settings.processArguments(List("-cp", classpath), true) + settings + } +}
\ No newline at end of file |