diff options
author | Eugene Burmako <xeno.by@gmail.com> | 2014-01-28 12:23:47 +0300 |
---|---|---|
committer | Eugene Burmako <xeno.by@gmail.com> | 2014-02-14 14:16:42 +0100 |
commit | 202eb73b6cd6ebb3e20ff9f0a198c4ea83319851 (patch) | |
tree | 1fb59abe86590e8c03baff04099f2eda5bc788ac /test/files/run/showdecl/Test_2.scala | |
parent | ada0252d4494611904c15cc5da72654c1a180a8f (diff) | |
download | scala-202eb73b6cd6ebb3e20ff9f0a198c4ea83319851.tar.gz scala-202eb73b6cd6ebb3e20ff9f0a198c4ea83319851.tar.bz2 scala-202eb73b6cd6ebb3e20ff9f0a198c4ea83319851.zip |
adds showDeclaration(sym: Symbol): String
As per Paul’s request, this commit exposes Symbol.defString, although
in a different way to ensure consistency with our other prettyprinting
facilities provided in the reflection API.
Diffstat (limited to 'test/files/run/showdecl/Test_2.scala')
-rw-r--r-- | test/files/run/showdecl/Test_2.scala | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/files/run/showdecl/Test_2.scala b/test/files/run/showdecl/Test_2.scala new file mode 100644 index 0000000000..65ab2f147c --- /dev/null +++ b/test/files/run/showdecl/Test_2.scala @@ -0,0 +1,32 @@ +import scala.reflect.runtime.universe._ +import scala.reflect.runtime.{currentMirror => cm} + +object Test extends App { + def test(sym: Symbol): Unit = { + println(s"autoinitialized ${sym.name}: ${showDeclaration(sym)}") + sym.typeSignature + println(s"autoinitialized ${sym.name}: ${showDeclaration(sym)}") + } + + Macros.foo + println("runtime") + test(symbolOf[D]) + test(typeOf[D].member(TermName("x"))) + test(typeOf[D].member(TermName("y"))) + test(typeOf[D].member(TermName("z"))) + test(typeOf[D].member(TermName("t"))) + test(typeOf[D].member(TypeName("W"))) + test(typeOf[D].member(TypeName("C"))) + test(typeOf[D].member(TermName("O"))) +} + +class C +class D extends C { + val x = 2 + lazy val y = 3 + var z = 4 + def t[T <: Int](x: D)(y: x.W) = 5 + type W = String + class C extends D + object O extends C +} |