Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

SI-5999 removes the macro context mirror

It is impossible to enforce macro programmers to use this mirror
instead of c.universe.rootMirror, so it has to be let go.

As to packageless symbol loading, which was the sole purpose of
introducing a special mirror for macro contexts, it will be integrated
into the compiler mirror in subsequent commits.
  • Loading branch information...
commit 96036b35698f735fd0e91aead8085519b5c3ce43 1 parent dc7cef8
Eugene Burmako xeno-by authored
3  src/compiler/scala/reflect/makro/runtime/Context.scala
View
@@ -8,7 +8,6 @@ abstract class Context extends scala.reflect.makro.Context
with CapturedVariables
with Infrastructure
with Enclosures
- with Mirrors
with Names
with Reifiers
with FrontEnds
@@ -23,7 +22,7 @@ abstract class Context extends scala.reflect.makro.Context
val universe: Global
- val mirror: MirrorOf[universe.type] = new ContextMirror
+ val mirror: MirrorOf[universe.type] = universe.rootMirror
val callsiteTyper: universe.analyzer.Typer
43 src/compiler/scala/reflect/makro/runtime/Mirrors.scala
View
@@ -1,43 +0,0 @@
-package scala.reflect.makro
-package runtime
-
-import scala.tools.nsc.util.ScalaClassLoader
-
-trait Mirrors {
- self: Context =>
-
- import universe._
- import definitions._
-
- class ContextMirror extends RootsBase(NoSymbol) {
- val universe: self.universe.type = self.universe
- def rootLoader: LazyType = rootMirror.rootLoader
-
- val RootPackage = rootMirror.RootPackage
- val RootClass = rootMirror.RootClass
- val EmptyPackage = rootMirror.EmptyPackage
- val EmptyPackageClass = rootMirror.EmptyPackageClass
-
- // [Eugene++] this still doesn't solve the problem of invoking `c.typeCheck` on the code that refers to packageless symbols
- override protected def mirrorMissingHook(owner: Symbol, name: Name): Symbol = {
- if (owner.isRoot && isJavaClass(name.toString)) EmptyPackageClass.info decl name
- else NoSymbol
- }
-
- private lazy val libraryClasspathLoader: ClassLoader = {
- val classpath = platform.classPath.asURLs
- ScalaClassLoader.fromURLs(classpath)
- }
-
- private def isJavaClass(path: String): Boolean =
- try {
- Class.forName(path, true, libraryClasspathLoader)
- true
- } catch {
- case (_: ClassNotFoundException) | (_: NoClassDefFoundError) | (_: IncompatibleClassChangeError) =>
- false
- }
-
- override def toString = "macro context mirror"
- }
-}
Please sign in to comment.
Something went wrong with that request. Please try again.