diff options
author | clhodapp <clhodapp1@gmail.com> | 2012-07-06 07:04:50 -0500 |
---|---|---|
committer | clhodapp <clhodapp1@gmail.com> | 2012-07-08 19:18:50 -0500 |
commit | 713ce7c5bb01ecf10633193baa66aa7161c68be7 (patch) | |
tree | a95449c52c176c3feaba700eec401bc12c770404 /test/files/run/reflect-resolveoverload-variadic.scala | |
parent | f82a1d122cb20dc9924f80ebcc9d31da46bd4f29 (diff) | |
download | scala-713ce7c5bb01ecf10633193baa66aa7161c68be7.tar.gz scala-713ce7c5bb01ecf10633193baa66aa7161c68be7.tar.bz2 scala-713ce7c5bb01ecf10633193baa66aa7161c68be7.zip |
New logic for TermSymbol.resolveOverloaded
Diffstat (limited to 'test/files/run/reflect-resolveoverload-variadic.scala')
-rw-r--r-- | test/files/run/reflect-resolveoverload-variadic.scala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/files/run/reflect-resolveoverload-variadic.scala b/test/files/run/reflect-resolveoverload-variadic.scala new file mode 100644 index 0000000000..8e2e15600f --- /dev/null +++ b/test/files/run/reflect-resolveoverload-variadic.scala @@ -0,0 +1,27 @@ + +class C { + def foo(x: Int*) = 1 + x.sum + def foo(x: String) = 2 +} + +object Test extends App { + val cm = reflect.runtime.currentMirror + val u = cm.universe + val c = new C + val im = cm.reflect(c) + val foo = u.typeOf[C] member u.newTermName("foo") asTermSymbol + val f0 = foo.resolveOverloaded() + val f1 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[Int])) + val f2 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[Int], u.typeOf[Int])) + val f3 = foo.resolveOverloaded(posVargs = Seq(u.typeOf[String])) + + val m0 = im.reflectMethod(f0 asMethodSymbol) + val m1 = im.reflectMethod(f1 asMethodSymbol) + val m2 = im.reflectMethod(f2 asMethodSymbol) + val m3 = im.reflectMethod(f3 asMethodSymbol) + + assert(m0(Seq()) == c.foo()) + assert(m1(Seq(1)) == c.foo(1)) + assert(m2(Seq(4, 9)) == c.foo(4, 9)) + assert(m3("abc") == c.foo("abc")) +} |