diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-12-30 07:15:18 -0800 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-12-30 07:15:18 -0800 |
commit | 0d739d2acda8baea790d4b119ebbd185c1393107 (patch) | |
tree | f7053ec440bc07e5866ce6981aa7ef92eb6ba53a | |
parent | 49e9e468864c0e2315f03923ae771b24cf2140d6 (diff) | |
parent | 08a5e03280e305bf19904a1a4f80ab328eeaacab (diff) | |
download | scala-0d739d2acda8baea790d4b119ebbd185c1393107.tar.gz scala-0d739d2acda8baea790d4b119ebbd185c1393107.tar.bz2 scala-0d739d2acda8baea790d4b119ebbd185c1393107.zip |
Merge pull request #3314 from xeno-by/topic/roots
makes well-known packages and package classes consistent with each other
-rw-r--r-- | src/reflect/scala/reflect/internal/Mirrors.scala | 3 | ||||
-rw-r--r-- | test/junit/scala/reflect/internal/MirrorsTest.scala | 18 |
2 files changed, 20 insertions, 1 deletions
diff --git a/src/reflect/scala/reflect/internal/Mirrors.scala b/src/reflect/scala/reflect/internal/Mirrors.scala index 3a630b6a16..9c5a593ca5 100644 --- a/src/reflect/scala/reflect/internal/Mirrors.scala +++ b/src/reflect/scala/reflect/internal/Mirrors.scala @@ -281,7 +281,6 @@ trait Mirrors extends api.Mirrors { class RootPackage extends ModuleSymbol(rootOwner, NoPosition, nme.ROOTPKG) with RootSymbol { this setInfo NullaryMethodType(RootClass.tpe) - RootClass.sourceModule = this override def isRootPackage = true } @@ -296,6 +295,7 @@ trait Mirrors extends api.Mirrors { override def isRoot = true override def isEffectiveRoot = true override def isNestedClass = false + override def sourceModule = RootPackage } // This is <root>, the actual root of everything except the package _root_. @@ -316,6 +316,7 @@ trait Mirrors extends api.Mirrors { class EmptyPackageClass extends PackageClassSymbol(RootClass, NoPosition, tpnme.EMPTY_PACKAGE_NAME) with WellKnownSymbol { override def isEffectiveRoot = true override def isEmptyPackageClass = true + override def sourceModule = EmptyPackage } lazy val EmptyPackageClass = new EmptyPackageClass diff --git a/test/junit/scala/reflect/internal/MirrorsTest.scala b/test/junit/scala/reflect/internal/MirrorsTest.scala new file mode 100644 index 0000000000..9108af139f --- /dev/null +++ b/test/junit/scala/reflect/internal/MirrorsTest.scala @@ -0,0 +1,18 @@ +package scala.reflect.internal + +import org.junit.Assert._ +import org.junit.Test +import org.junit.runner.RunWith +import org.junit.runners.JUnit4 + +@RunWith(classOf[JUnit4]) +class MirrorsTest { + @Test def rootCompanionsAreConnected(): Unit = { + val cm = scala.reflect.runtime.currentMirror + import cm._ + assertEquals("RootPackage.moduleClass == RootClass", RootClass, RootPackage.moduleClass) + assertEquals("RootClass.module == RootPackage", RootPackage, RootClass.module) + assertEquals("EmptyPackage.moduleClass == EmptyPackageClass", EmptyPackageClass, EmptyPackage.moduleClass) + assertEquals("EmptyPackageClass.module == EmptyPackage", EmptyPackage, EmptyPackageClass.module) + } +}
\ No newline at end of file |