diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2012-07-31 11:33:16 +0200 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2012-08-02 15:50:52 +0200 |
commit | 027b00171c0d92ec669deaa471966e6468c6b8cf (patch) | |
tree | 63808014ea752c49ae39e0b731f0d15bc6edeb28 /test | |
parent | b578059b43a4caaadee2cb20f74cd9a7c876c8ef (diff) | |
download | scala-027b00171c0d92ec669deaa471966e6468c6b8cf.tar.gz scala-027b00171c0d92ec669deaa471966e6468c6b8cf.tar.bz2 scala-027b00171c0d92ec669deaa471966e6468c6b8cf.zip |
more refinements of reflection API
Added a bunch of test methods to symbols to cover public flags:
(e.g. isPrivate, isFinal, isOverride, isImplicit, etc). I'd argue that
the API duplication w.r.t flag sets is trumped by unified interface
to tests and better encapsulation.
Also updated the API to be easier to understand after prior exposure
to Java or .NET reflection APIs:
1) Added typeParams to TypeSymbol and ClassSymbol.
2) Renamed MethodSymbol.resultType to returnType.
3) Removed the distinction between MethodSymbol.params vs MethodSymbol.allParams
now we just have MethodSymbol.params: List[List[Symbol]].
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/reflection-methodsymbol-allparams.check | 8 | ||||
-rw-r--r-- | test/files/run/reflection-methodsymbol-allparams.scala | 24 | ||||
-rw-r--r-- | test/files/run/reflection-methodsymbol-params.check | 12 | ||||
-rw-r--r-- | test/files/run/reflection-methodsymbol-resulttype.scala | 24 | ||||
-rw-r--r-- | test/files/run/reflection-methodsymbol-returntype.check (renamed from test/files/run/reflection-methodsymbol-resulttype.check) | 0 | ||||
-rw-r--r-- | test/files/run/reflection-methodsymbol-returntype.scala | 24 |
6 files changed, 30 insertions, 62 deletions
diff --git a/test/files/run/reflection-methodsymbol-allparams.check b/test/files/run/reflection-methodsymbol-allparams.check deleted file mode 100644 index 11f349d52b..0000000000 --- a/test/files/run/reflection-methodsymbol-allparams.check +++ /dev/null @@ -1,8 +0,0 @@ -List()
-List(List())
-List(List(value x))
-List(List(value x), List(value y))
-List()
-List(List())
-List(List(value x))
-List(List(value x), List(value y))
diff --git a/test/files/run/reflection-methodsymbol-allparams.scala b/test/files/run/reflection-methodsymbol-allparams.scala deleted file mode 100644 index d7c1c281b0..0000000000 --- a/test/files/run/reflection-methodsymbol-allparams.scala +++ /dev/null @@ -1,24 +0,0 @@ -import scala.reflect.runtime.universe._ - -class C { - def x1: Int = ??? - def x2(): Int = ??? - def x3(x: Int): Int = ??? - def x4(x: Int)(y: Int): Int = ??? - - def y1[T]: Int = ??? - def y2[T](): Int = ??? - def y3[T](x: Int): Int = ??? - def y4[T](x: Int)(y: Int): Int = ??? -} - -object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.allParams) - println(typeOf[C].member(newTermName("x2")).asMethod.allParams) - println(typeOf[C].member(newTermName("x3")).asMethod.allParams) - println(typeOf[C].member(newTermName("x4")).asMethod.allParams) - println(typeOf[C].member(newTermName("y1")).asMethod.allParams) - println(typeOf[C].member(newTermName("y2")).asMethod.allParams) - println(typeOf[C].member(newTermName("y3")).asMethod.allParams) - println(typeOf[C].member(newTermName("y4")).asMethod.allParams) -}
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-params.check b/test/files/run/reflection-methodsymbol-params.check index 899ae15a0c..11f349d52b 100644 --- a/test/files/run/reflection-methodsymbol-params.check +++ b/test/files/run/reflection-methodsymbol-params.check @@ -1,8 +1,8 @@ List()
+List(List())
+List(List(value x))
+List(List(value x), List(value y))
List()
-List(value x)
-List(value x)
-List()
-List()
-List(value x)
-List(value x)
+List(List())
+List(List(value x))
+List(List(value x), List(value y))
diff --git a/test/files/run/reflection-methodsymbol-resulttype.scala b/test/files/run/reflection-methodsymbol-resulttype.scala deleted file mode 100644 index 0e3de26b9f..0000000000 --- a/test/files/run/reflection-methodsymbol-resulttype.scala +++ /dev/null @@ -1,24 +0,0 @@ -import scala.reflect.runtime.universe._ - -class C { - def x1: Int = ??? - def x2(): Int = ??? - def x3(x: Int): Int = ??? - def x4(x: Int)(y: Int): Int = ??? - - def y1[T]: Int = ??? - def y2[T](): Int = ??? - def y3[T](x: Int): Int = ??? - def y4[T](x: Int)(y: Int): Int = ??? -} - -object Test extends App { - println(typeOf[C].member(newTermName("x1")).asMethod.resultType) - println(typeOf[C].member(newTermName("x2")).asMethod.resultType) - println(typeOf[C].member(newTermName("x3")).asMethod.resultType) - println(typeOf[C].member(newTermName("x4")).asMethod.resultType) - println(typeOf[C].member(newTermName("y1")).asMethod.resultType) - println(typeOf[C].member(newTermName("y2")).asMethod.resultType) - println(typeOf[C].member(newTermName("y3")).asMethod.resultType) - println(typeOf[C].member(newTermName("y4")).asMethod.resultType) -}
\ No newline at end of file diff --git a/test/files/run/reflection-methodsymbol-resulttype.check b/test/files/run/reflection-methodsymbol-returntype.check index 0f30d1beaf..0f30d1beaf 100644 --- a/test/files/run/reflection-methodsymbol-resulttype.check +++ b/test/files/run/reflection-methodsymbol-returntype.check diff --git a/test/files/run/reflection-methodsymbol-returntype.scala b/test/files/run/reflection-methodsymbol-returntype.scala new file mode 100644 index 0000000000..392754dbe4 --- /dev/null +++ b/test/files/run/reflection-methodsymbol-returntype.scala @@ -0,0 +1,24 @@ +import scala.reflect.runtime.universe._ + +class C { + def x1: Int = ??? + def x2(): Int = ??? + def x3(x: Int): Int = ??? + def x4(x: Int)(y: Int): Int = ??? + + def y1[T]: Int = ??? + def y2[T](): Int = ??? + def y3[T](x: Int): Int = ??? + def y4[T](x: Int)(y: Int): Int = ??? +} + +object Test extends App { + println(typeOf[C].member(newTermName("x1")).asMethod.returnType) + println(typeOf[C].member(newTermName("x2")).asMethod.returnType) + println(typeOf[C].member(newTermName("x3")).asMethod.returnType) + println(typeOf[C].member(newTermName("x4")).asMethod.returnType) + println(typeOf[C].member(newTermName("y1")).asMethod.returnType) + println(typeOf[C].member(newTermName("y2")).asMethod.returnType) + println(typeOf[C].member(newTermName("y3")).asMethod.returnType) + println(typeOf[C].member(newTermName("y4")).asMethod.returnType) +}
\ No newline at end of file |