Skip to content
This repository
Browse code

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 authored July 17, 2012
3  src/compiler/scala/reflect/makro/runtime/Context.scala
@@ -8,7 +8,6 @@ abstract class Context extends scala.reflect.makro.Context
8 8
                          with CapturedVariables
9 9
                          with Infrastructure
10 10
                          with Enclosures
11  
-                         with Mirrors
12 11
                          with Names
13 12
                          with Reifiers
14 13
                          with FrontEnds
@@ -23,7 +22,7 @@ abstract class Context extends scala.reflect.makro.Context
23 22
 
24 23
   val universe: Global
25 24
 
26  
-  val mirror: MirrorOf[universe.type] = new ContextMirror
  25
+  val mirror: MirrorOf[universe.type] = universe.rootMirror
27 26
 
28 27
   val callsiteTyper: universe.analyzer.Typer
29 28
 
43  src/compiler/scala/reflect/makro/runtime/Mirrors.scala
... ...
@@ -1,43 +0,0 @@
1  
-package scala.reflect.makro
2  
-package runtime
3  
-
4  
-import scala.tools.nsc.util.ScalaClassLoader
5  
-
6  
-trait Mirrors {
7  
-  self: Context =>
8  
-
9  
-  import universe._
10  
-  import definitions._
11  
-
12  
-  class ContextMirror extends RootsBase(NoSymbol) {
13  
-    val universe: self.universe.type = self.universe
14  
-    def rootLoader: LazyType = rootMirror.rootLoader
15  
-
16  
-    val RootPackage = rootMirror.RootPackage
17  
-    val RootClass = rootMirror.RootClass
18  
-    val EmptyPackage = rootMirror.EmptyPackage
19  
-    val EmptyPackageClass = rootMirror.EmptyPackageClass
20  
-
21  
-    // [Eugene++] this still doesn't solve the problem of invoking `c.typeCheck` on the code that refers to packageless symbols
22  
-    override protected def mirrorMissingHook(owner: Symbol, name: Name): Symbol = {
23  
-      if (owner.isRoot && isJavaClass(name.toString)) EmptyPackageClass.info decl name
24  
-      else NoSymbol
25  
-    }
26  
-
27  
-    private lazy val libraryClasspathLoader: ClassLoader = {
28  
-      val classpath = platform.classPath.asURLs
29  
-      ScalaClassLoader.fromURLs(classpath)
30  
-    }
31  
-
32  
-    private def isJavaClass(path: String): Boolean =
33  
-      try {
34  
-        Class.forName(path, true, libraryClasspathLoader)
35  
-        true
36  
-      } catch {
37  
-        case (_: ClassNotFoundException) | (_: NoClassDefFoundError) | (_: IncompatibleClassChangeError) =>
38  
-        false
39  
-      }
40  
-
41  
-    override def toString = "macro context mirror"
42  
-  }
43  
-}

0 notes on commit 96036b3

Please sign in to comment.
Something went wrong with that request. Please try again.