summaryrefslogtreecommitdiff
path: root/test/files/run/shortClass.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-09-29 14:20:21 -0700
committerPaul Phillips <paulp@improving.org>2012-09-29 15:01:57 -0700
commit29a59700b4cf1ade91abb6020ba4814be5ef88e7 (patch)
tree72e08ca9fed178bc4166ea00c1521b4d7b4a7975 /test/files/run/shortClass.scala
parent2e14b0771569b4fb6cd0273e1480f69c18743832 (diff)
downloadscala-29a59700b4cf1ade91abb6020ba4814be5ef88e7.tar.gz
scala-29a59700b4cf1ade91abb6020ba4814be5ef88e7.tar.bz2
scala-29a59700b4cf1ade91abb6020ba4814be5ef88e7.zip
Added utility function shortClass.
Pretty sick of names like scala> typeOf[List[Int]].getClass.getName res0: String = scala.reflect.internal.Types$TypeRef$$anon$1 I wrote this so I can see what the class of some arbitrary thing is in a way which my little brain can understand. For the example above we get scala> shortClassOfInstance(typeOf[List[Int]]) res0: String = ArgsTypeRef with AliasTypeRef Let's pimp a "shortClassName" onto AnyRef and be happy.
Diffstat (limited to 'test/files/run/shortClass.scala')
-rw-r--r--test/files/run/shortClass.scala24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/files/run/shortClass.scala b/test/files/run/shortClass.scala
new file mode 100644
index 0000000000..b7bb016896
--- /dev/null
+++ b/test/files/run/shortClass.scala
@@ -0,0 +1,24 @@
+import scala.reflect.internal.util._
+
+package bippity {
+ trait DingDongBippy
+
+ package bop {
+ class Foo {
+ class Bar
+ object Bar
+ }
+ }
+}
+
+object Test {
+ import bippity._
+ import bop._
+
+ def main(args: Array[String]): Unit = {
+ val f = new Foo
+ val instances = List(f, new f.Bar, f.Bar, new Foo with DingDongBippy, new f.Bar with DingDongBippy)
+ instances map (_.getClass.getName) foreach println
+ instances map shortClassOfInstance foreach println
+ }
+}