From a727c6fc198d33842ff85d8a16d48143a6757d51 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Mon, 30 Jul 2012 13:17:17 +0200 Subject: 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). --- test/files/run/reflection-simple.check | 45 -------------------------- test/files/run/reflection-simple.scala | 12 ------- test/files/run/reflection-sorted-decls.check | 7 ++++ test/files/run/reflection-sorted-decls.scala | 8 +++++ test/files/run/reflection-sorted-members.check | 34 +++++++++++++++++++ test/files/run/reflection-sorted-members.scala | 11 +++++++ 6 files changed, 60 insertions(+), 57 deletions(-) delete mode 100644 test/files/run/reflection-simple.check delete mode 100644 test/files/run/reflection-simple.scala create mode 100644 test/files/run/reflection-sorted-decls.check create mode 100644 test/files/run/reflection-sorted-decls.scala create mode 100644 test/files/run/reflection-sorted-members.check create mode 100644 test/files/run/reflection-sorted-members.scala (limited to 'test/files/run') diff --git a/test/files/run/reflection-simple.check b/test/files/run/reflection-simple.check deleted file mode 100644 index 671d9d2716..0000000000 --- a/test/files/run/reflection-simple.check +++ /dev/null @@ -1,45 +0,0 @@ -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 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-sorted-members.check b/test/files/run/reflection-sorted-members.check new file mode 100644 index 0000000000..d58b691c42 --- /dev/null +++ b/test/files/run/reflection-sorted-members.check @@ -0,0 +1,34 @@ +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 + } +} -- cgit v1.2.3