diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-09-18 12:47:21 -0700 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-09-18 12:47:21 -0700 |
commit | afef5fea6e2de37344a80a01840ec3c2faef7530 (patch) | |
tree | a5be2f41bf8f3a59d8ba3217f2ccef32d561909a /test | |
parent | c9b2ef64108d75ab41ff95cc32bc503e77653e66 (diff) | |
parent | 22270c68a12587d0125bd4f14c9d9f4cdcdb24d5 (diff) | |
download | scala-afef5fea6e2de37344a80a01840ec3c2faef7530.tar.gz scala-afef5fea6e2de37344a80a01840ec3c2faef7530.tar.bz2 scala-afef5fea6e2de37344a80a01840ec3c2faef7530.zip |
Merge pull request #1324 from scalamacros/ticket/6374
Scala reflection now supports Java CRTP
Diffstat (limited to 'test')
-rw-r--r-- | test/files/lib/javac-artifacts.jar.desired.sha1 | 1 | ||||
-rw-r--r-- | test/files/run/reflection-java-annotations.check | 23 | ||||
-rw-r--r-- | test/files/run/reflection-java-annotations.jar.desired.sha1 | 1 | ||||
-rw-r--r-- | test/files/run/reflection-java-annotations.scala | 25 | ||||
-rw-r--r-- | test/files/run/reflection-java-crtp.check | 1 | ||||
-rw-r--r-- | test/files/run/reflection-java-crtp.scala | 8 |
6 files changed, 17 insertions, 42 deletions
diff --git a/test/files/lib/javac-artifacts.jar.desired.sha1 b/test/files/lib/javac-artifacts.jar.desired.sha1 new file mode 100644 index 0000000000..8dbbc1d451 --- /dev/null +++ b/test/files/lib/javac-artifacts.jar.desired.sha1 @@ -0,0 +1 @@ +c5788c5e518eb267445c5a995fd98b2210f90a58 ?javac-artifacts.jar diff --git a/test/files/run/reflection-java-annotations.check b/test/files/run/reflection-java-annotations.check index 84cfd03358..53c53cfbcc 100644 --- a/test/files/run/reflection-java-annotations.check +++ b/test/files/run/reflection-java-annotations.check @@ -1,22 +1 @@ -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 sym = typeOf[Foo].typeSymbol
-sym: reflect.runtime.universe.Symbol = class Foo
-
-scala> sym.typeSignature
-res0: reflect.runtime.universe.Type = java.lang.Object{def <init>(): Foo}
-
-scala> sym.getAnnotations foreach (_.javaArgs)
-
-scala> println(sym.getAnnotations)
-List(ComplexAnnotation(v1 = 1, v10 = "hello", v101 = [101, 101], v102 = [102, 102], v103 = ['g', 'g'], v104 = [104, 104], v105 = [105L, 105L], v106 = [106.0, 106.0], v107 = [107.0, 107.0], v108 = [false, true], v11 = classOf[Foo], v110 = ["hello", "world"], v111 = [classOf[SimpleAnnotation], classOf[ComplexAnnotation]], v113 = [SimpleAnnotation(v1 = 21, v10 = "world2", v11 = classOf[ComplexAnnotation], v2 = 22, v3 = '\027', v4 = 24, v5 = 25L, v6 = 26.0, v7 = 27.0, v8 = false)], v13 = SimpleAnnotation(v1 = 11, v10 = "world1", v11 = classOf[SimpleAnnotation], v2 = 12, v3 = '\r', v4 = 14, v5 = 15L, v6 = 16.0, v7 = 17.0, v8 = false), v2 = 2, v3 = '\03', v4 = 4, v5 = 5L, v6 = 6.0, v7 = 7.0, v8 = false))
-
-scala>
-
-scala>
+List(JavaComplexAnnotation(v1 = 1, v10 = "hello", v101 = [101, 101], v102 = [102, 102], v103 = ['g', 'g'], v104 = [104, 104], v105 = [105L, 105L], v106 = [106.0, 106.0], v107 = [107.0, 107.0], v108 = [false, true], v11 = classOf[JavaAnnottee], v110 = ["hello", "world"], v111 = [classOf[JavaSimpleAnnotation], classOf[JavaComplexAnnotation]], v112 = [FOO, BAR], v113 = [JavaSimpleAnnotation(v1 = 21, v10 = "world2", v11 = classOf[JavaComplexAnnotation], v12 = BAR, v2 = 22, v3 = '\027', v4 = 24, v5 = 25L, v6 = 26.0, v7 = 27.0, v8 = false)], v12 = FOO, v13 = JavaSimpleAnnotation(v1 = 11, v10 = "world1", v11 = classOf[JavaSimpleAnnotation], v12 = FOO, v2 = 12, v3 = '\r', v4 = 14, v5 = 15L, v6 = 16.0, v7 = 17.0, v8 = false), v2 = 2, v3 = '\03', v4 = 4, v5 = 5L, v6 = 6.0, v7 = 7.0, v8 = false)) diff --git a/test/files/run/reflection-java-annotations.jar.desired.sha1 b/test/files/run/reflection-java-annotations.jar.desired.sha1 deleted file mode 100644 index 430e7626e6..0000000000 --- a/test/files/run/reflection-java-annotations.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -c35876a529c6be33bdda7b3f48ac8ae800d2f36a ?reflection-java-annotations.jar diff --git a/test/files/run/reflection-java-annotations.scala b/test/files/run/reflection-java-annotations.scala index 4a4fe2572d..0b16c0d103 100644 --- a/test/files/run/reflection-java-annotations.scala +++ b/test/files/run/reflection-java-annotations.scala @@ -1,20 +1,7 @@ -import scala.tools.partest._ -import scala.tools.nsc.Settings - -object Test extends ReplTest { - def code = """ - import scala.reflect.runtime.universe._ - val sym = typeOf[Foo].typeSymbol - sym.typeSignature - sym.getAnnotations foreach (_.javaArgs) - println(sym.getAnnotations) - """ - - 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 - } +object Test extends App { + import scala.reflect.runtime.universe._ + val sym = typeOf[JavaAnnottee].typeSymbol + sym.typeSignature + sym.getAnnotations foreach (_.javaArgs) + println(sym.getAnnotations) }
\ No newline at end of file diff --git a/test/files/run/reflection-java-crtp.check b/test/files/run/reflection-java-crtp.check new file mode 100644 index 0000000000..3e5a77e93a --- /dev/null +++ b/test/files/run/reflection-java-crtp.check @@ -0,0 +1 @@ +(type E,type E,true) diff --git a/test/files/run/reflection-java-crtp.scala b/test/files/run/reflection-java-crtp.scala new file mode 100644 index 0000000000..260d3540dc --- /dev/null +++ b/test/files/run/reflection-java-crtp.scala @@ -0,0 +1,8 @@ +object Test extends App { + import scala.reflect.runtime.universe._ + val enum = typeOf[JavaSimpleEnumeration].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(_, TypeRef(_, _, List(TypeRef(_, e2: TypeSymbol, _)))) = e1.typeSignature + println(e1, e2, e1 eq e2) +}
\ No newline at end of file |