diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-07-30 13:17:17 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-02 15:36:55 +0200 |
commit | a727c6fc198d33842ff85d8a16d48143a6757d51 (patch) | |
tree | 3b995ade8066488c3ac42d7b65e0bb02b976cabc /test | |
parent | 937da62be2834a646a31dbfb01527a82672f111e (diff) | |
download | scala-a727c6fc198d33842ff85d8a16d48143a6757d51.tar.gz scala-a727c6fc198d33842ff85d8a16d48143a6757d51.tar.bz2 scala-a727c6fc198d33842ff85d8a16d48143a6757d51.zip |
SI-5732 members and derivatives now return Scope
Firstly this unifies the reflection API - now both decls and members
return Scope (not Scope and List[Symbol] as it were before).
Secondly this fixes SI-5732 without having to sort the result of members.
Type.members now returns Scope, a distinguished type, which has the
`sorted` method, which does the required sorting if necessary.
Also removes nonPrivateMembers and nonPrivateDeclarations to keep the API
minimalistic (as can be seen from their implementation in internal.Types
they are just members and decls with bridges and private members removed).
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/reflection-simple.scala | 12 | ||||
-rw-r--r-- | test/files/run/reflection-sorted-decls.check | 7 | ||||
-rw-r--r-- | test/files/run/reflection-sorted-decls.scala | 8 | ||||
-rw-r--r-- | test/files/run/reflection-sorted-members.check (renamed from test/files/run/reflection-simple.check) | 79 | ||||
-rw-r--r-- | test/files/run/reflection-sorted-members.scala | 11 |
5 files changed, 60 insertions, 57 deletions
diff --git a/test/files/run/reflection-simple.scala b/test/files/run/reflection-simple.scala deleted file mode 100644 index ec34b71cec..0000000000 --- a/test/files/run/reflection-simple.scala +++ /dev/null @@ -1,12 +0,0 @@ -// a.scala -// Wed May 2 01:01:22 PDT 2012 - -object Test { - def main(args: Array[String]) { - System.out.println("Running") - case class Foo(a: Int, b: Int, c: Int) - import scala.reflect.runtime.{currentMirror => cm} - val props = cm.classSymbol(classOf[Foo]).typeSignature.members.filter(_.isTerm).map(_.toString) - props.toList.sorted foreach System.out.println - } -} diff --git a/test/files/run/reflection-sorted-decls.check b/test/files/run/reflection-sorted-decls.check new file mode 100644 index 0000000000..9a9832a683 --- /dev/null +++ b/test/files/run/reflection-sorted-decls.check @@ -0,0 +1,7 @@ +value a
+value b
+value c
+method c
+method b
+method a
+constructor Foo$1
diff --git a/test/files/run/reflection-sorted-decls.scala b/test/files/run/reflection-sorted-decls.scala new file mode 100644 index 0000000000..242f17d9bb --- /dev/null +++ b/test/files/run/reflection-sorted-decls.scala @@ -0,0 +1,8 @@ +object Test { + def main(args: Array[String]) { + class Foo(val a: Int, val b: Int, val c: Int) + import scala.reflect.runtime.{currentMirror => cm} + val decls = cm.classSymbol(classOf[Foo]).typeSignature.declarations + decls.sorted.toList foreach System.out.println + } +} diff --git a/test/files/run/reflection-simple.check b/test/files/run/reflection-sorted-members.check index 671d9d2716..d58b691c42 100644 --- a/test/files/run/reflection-simple.check +++ b/test/files/run/reflection-sorted-members.check @@ -1,45 +1,34 @@ -Running -constructor Foo$3 -constructor Object -method != -method != -method ## -method $asInstanceOf -method $init$ -method $isInstanceOf -method == -method == -method _1 -method _2 -method _3 -method a -method asInstanceOf -method b -method c -method canEqual -method clone -method copy -method copy$default$1 -method copy$default$2 -method copy$default$3 -method eq -method equals -method finalize -method getClass -method hashCode -method isInstanceOf -method ne -method notify -method notifyAll -method productArity -method productElement -method productIterator -method productPrefix -method synchronized -method toString -method wait -method wait -method wait -value a -value b -value c +value a
+value b
+value c
+method c
+method b
+method a
+constructor Foo$1
+value x
+method x
+constructor Bar$1
+method finalize
+method wait
+method wait
+method wait
+method equals
+method toString
+method hashCode
+method getClass
+method clone
+method notify
+method notifyAll
+constructor Object
+method eq
+method ne
+method ==
+method !=
+method ##
+method synchronized
+method $isInstanceOf
+method $asInstanceOf
+method ==
+method !=
+method isInstanceOf
+method asInstanceOf
diff --git a/test/files/run/reflection-sorted-members.scala b/test/files/run/reflection-sorted-members.scala new file mode 100644 index 0000000000..9980d79999 --- /dev/null +++ b/test/files/run/reflection-sorted-members.scala @@ -0,0 +1,11 @@ +object Test { + def main(args: Array[String]) { + trait T1 { def a: Int; def c: Int } + trait T2 { def a: Int; def b: Int } + class Bar(val x: Int) + class Foo(val a: Int, val b: Int, val c: Int) extends Bar(a + b + c) with T1 with T2 + import scala.reflect.runtime.{currentMirror => cm} + val members = cm.classSymbol(classOf[Foo]).typeSignature.members + members.sorted.toList foreach System.out.println + } +} |