diff options
author | Josh Suereth <joshua.suereth@gmail.com> | 2012-09-12 10:46:45 -0400 |
---|---|---|
committer | Josh Suereth <joshua.suereth@gmail.com> | 2012-09-13 13:04:23 -0400 |
commit | 7861ed6886ecf827907a6b48f0628395f199f49b (patch) | |
tree | feae260b291c0fe1a819dd3109ac3f841ca90a39 /test/files/run/toolbox_typecheck_macrosdisabled2.check | |
parent | 76d4e9a8071f9e102106696664376b7f70622582 (diff) | |
download | scala-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/run/toolbox_typecheck_macrosdisabled2.check')
-rw-r--r-- | test/files/run/toolbox_typecheck_macrosdisabled2.check | 73 |
1 files changed, 41 insertions, 32 deletions
diff --git a/test/files/run/toolbox_typecheck_macrosdisabled2.check b/test/files/run/toolbox_typecheck_macrosdisabled2.check index d344e33180..149c3def12 100644 --- a/test/files/run/toolbox_typecheck_macrosdisabled2.check +++ b/test/files/run/toolbox_typecheck_macrosdisabled2.check @@ -1,32 +1,41 @@ -{
- val $u: ru.type = ru;
- val $m: $u.Mirror = ru.rootMirror;
- $u.Expr.apply[Array[Int]]($m, {
- final class $treecreator1 extends TreeCreator {
- def <init>(): $treecreator1 = {
- $treecreator1.super.<init>();
- ()
- };
- def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = {
- val $u: U = $m$untyped.universe;
- val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2))))
- }
- };
- new $treecreator1()
- })($u.TypeTag.apply[Array[Int]]($m, {
- final class $typecreator2 extends TypeCreator {
- def <init>(): $typecreator2 = {
- $typecreator2.super.<init>();
- ()
- };
- def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = {
- val $u: U = $m$untyped.universe;
- val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror];
- $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor))
- }
- };
- new $typecreator2()
- }))
-}
-ru.reify[Array[Int]](scala.Array.apply(2))
+{ + val $u: ru.type = ru; + val $m: $u.Mirror = ru.runtimeMirror({ + final class $anon extends scala.AnyRef { + def <init>(): anonymous class $anon = { + $anon.super.<init>(); + () + }; + () + }; + new $anon() +}.getClass().getClassLoader()); + $u.Expr.apply[Array[Int]]($m, { + final class $treecreator1 extends TreeCreator { + def <init>(): $treecreator1 = { + $treecreator1.super.<init>(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Tree = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.Apply.apply($u.Select.apply($u.Select.apply($u.build.Ident($m.staticPackage("scala")), $u.newTermName("Array")), $u.newTermName("apply")), scala.collection.immutable.List.apply[$u.Literal]($u.Literal.apply($u.Constant.apply(2)))) + } + }; + new $treecreator1() + })($u.TypeTag.apply[Array[Int]]($m, { + final class $typecreator2 extends TypeCreator { + def <init>(): $typecreator2 = { + $typecreator2.super.<init>(); + () + }; + def apply[U <: scala.reflect.base.Universe with Singleton]($m$untyped: scala.reflect.base.MirrorOf[U]): U#Type = { + val $u: U = $m$untyped.universe; + val $m: $u.Mirror = $m$untyped.asInstanceOf[$u.Mirror]; + $u.TypeRef.apply($u.ThisType.apply($m.staticPackage("scala").asModule.moduleClass), $m.staticClass("scala.Array"), scala.collection.immutable.List.apply[$u.Type]($m.staticClass("scala.Int").asType.toTypeConstructor)) + } + }; + new $typecreator2() + })) +} +ru.reify[Array[Int]](scala.Array.apply(2)) |