summaryrefslogtreecommitdiff
path: root/test/files/pos/t6259.scala
diff options
context:
space:
mode:
authorJosh Suereth <joshua.suereth@gmail.com>2012-09-12 10:46:45 -0400
committerJosh Suereth <joshua.suereth@gmail.com>2012-09-13 13:04:23 -0400
commit7861ed6886ecf827907a6b48f0628395f199f49b (patch)
treefeae260b291c0fe1a819dd3109ac3f841ca90a39 /test/files/pos/t6259.scala
parent76d4e9a8071f9e102106696664376b7f70622582 (diff)
downloadscala-7861ed6886ecf827907a6b48f0628395f199f49b.tar.gz
scala-7861ed6886ecf827907a6b48f0628395f199f49b.tar.bz2
scala-7861ed6886ecf827907a6b48f0628395f199f49b.zip
Fixes SI-6259. Unable to use typeOf in super call of top-level object.
This works around the issue of the inability to use classOf for top-level object classes by inventing a new anonymous class and instantiating it just to grab its class. Since the class is a nested type of the top-level object it'll be in the same classloader unless some kind of evil behavior is afoot. This patch should be undone if ever SI-2453 ever gets fixed, or we wind up with a direct way to grab the class of an object.
Diffstat (limited to 'test/files/pos/t6259.scala')
-rw-r--r--test/files/pos/t6259.scala47
1 files changed, 47 insertions, 0 deletions
diff --git a/test/files/pos/t6259.scala b/test/files/pos/t6259.scala
new file mode 100644
index 0000000000..43361c417e
--- /dev/null
+++ b/test/files/pos/t6259.scala
@@ -0,0 +1,47 @@
+package t6259
+
+import scala.reflect.runtime.universe._
+
+class A[X](implicit val tt: TypeTag[X]) {}
+object B extends A[String]
+
+object C {
+ object D extends A[String]
+}
+
+trait E {
+ object F extends A[String]
+}
+
+class G {
+ object H extends A[String]
+}
+
+object Test {
+ val x = {
+ object InVal extends A[String]
+ 5
+ }
+
+}
+
+// Note: Both of these fail right now.
+
+trait NeedsEarly {
+ val x: AnyRef
+}
+
+object Early extends {
+ // Drops to this.getClass and is not ok...
+ val x = { object EarlyOk extends A[String]; EarlyOk }
+} with NeedsEarly
+
+
+class DoubleTrouble[X](x: AnyRef)(implicit override val tt: TypeTag[X]) extends A[X]
+
+object DoubleOk extends DoubleTrouble[String]({
+ // Drops to this.getClass and is an issue
+ object InnerTrouble extends A[String];
+ InnerTrouble
+})
+