summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Macros.scala4
-rw-r--r--src/compiler/scala/tools/reflect/FastTrack.scala9
2 files changed, 9 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
index 9cf92ca5b9..f4456998c0 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala
@@ -42,7 +42,7 @@ import Fingerprint._
* (Expr(elems))
* (TypeTag(Int))
*/
-trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
+trait Macros extends MacroRuntimes with Traces with Helpers {
self: Analyzer =>
import global._
@@ -50,6 +50,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers {
import treeInfo.{isRepeatedParamType => _, _}
import MacrosStats._
+ lazy val fastTrack = new FastTrack[self.type](self)
+
def globalSettings = global.settings
protected def findMacroClassLoader(): ClassLoader = {
diff --git a/src/compiler/scala/tools/reflect/FastTrack.scala b/src/compiler/scala/tools/reflect/FastTrack.scala
index 8630ecf69e..64cf3d0847 100644
--- a/src/compiler/scala/tools/reflect/FastTrack.scala
+++ b/src/compiler/scala/tools/reflect/FastTrack.scala
@@ -10,14 +10,18 @@ import scala.tools.reflect.quasiquotes.{ Quasiquotes => QuasiquoteImpls }
/** Optimizes system macro expansions by hardwiring them directly to their implementations
* bypassing standard reflective load and invoke to avoid the overhead of Java/Scala reflection.
*/
-trait FastTrack {
- self: Macros with Analyzer =>
+class FastTrack[MacrosAndAnalyzer <: Macros with Analyzer](val macros: MacrosAndAnalyzer) {
+ import macros._
import global._
import definitions._
import scala.language.implicitConversions
import treeInfo.Applied
+ def contains(symbol: Symbol): Boolean = fastTrackCache().contains(symbol)
+ def apply(symbol: Symbol): FastTrackEntry = fastTrackCache().apply(symbol)
+ def get(symbol: Symbol): Option[FastTrackEntry] = fastTrackCache().get(symbol)
+
private implicit def context2taggers(c0: MacroContext): Taggers { val c: c0.type } =
new { val c: c0.type = c0 } with Taggers
private implicit def context2macroimplementations(c0: MacroContext): FormatInterpolator { val c: c0.type } =
@@ -39,7 +43,6 @@ trait FastTrack {
}
/** A map from a set of pre-established macro symbols to their implementations. */
- def fastTrack: Map[Symbol, FastTrackEntry] = fastTrackCache()
private val fastTrackCache = perRunCaches.newGeneric[Map[Symbol, FastTrackEntry]] {
val runDefinitions = currentRun.runDefinitions
import runDefinitions._