From a5127a8392fd2a0bce9b3ced302b4ebe1a80bc65 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Tue, 29 Oct 2013 16:04:17 +0100 Subject: SI-7678 Don't cache member symbols of TypeTags in Definitions. It we can only safely use vals in Definitions for top-level symbols. Otherwise, when the IDE switches to loading the symbol from source, we can hold on to a stale symbol, which in turn impedes implicit materialization of TypeTags. This commit moves (most) of the accessors for member symbols into RunDefinitions, and changes calling code accordingly. This is a win for presentation compiler correctness, and might even shave of a few cycles. In a few cases, I have had to leave a `def` to a member symbol in Definitions so we can get to it from the SymbolTable cake, which doesn't see RunDefinitions. The macro FastTrack facility now correctly recreates the mapping from Symbol to macro implementation each run, using a new facility in perRunCaches to create a run-indexed cache. The enclosed test recreates the situation reported in the ticket, in which TypeTags.scala is loaded from source. --- src/compiler/scala/tools/nsc/typechecker/Macros.scala | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/compiler/scala/tools/nsc/typechecker/Macros.scala') diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index d1045757a5..02fb70f3e5 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -104,7 +104,10 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { targs: List[Tree]) { // Was this binding derived from a `def ... = macro ???` definition? - def is_??? = className == Predef_???.owner.javaClassName && methName == Predef_???.name.encoded + def is_??? = { + val Predef_??? = currentRun.runDefinitions.Predef_??? + className == Predef_???.owner.javaClassName && methName == Predef_???.name.encoded + } } /** Macro def -> macro impl bindings are serialized into a `macroImpl` annotation @@ -146,6 +149,8 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { } def pickle(macroImplRef: Tree): Tree = { + val runDefinitions = currentRun.runDefinitions + import runDefinitions._ val MacroImplReference(isBundle, owner, macroImpl, targs) = macroImplRef // todo. refactor when fixing SI-5498 @@ -311,7 +316,7 @@ trait Macros extends FastTrack with MacroRuntimes with Traces with Helpers { def fail() = { if (macroDef != null) macroDef setFlag IS_ERROR; macroDdef setType ErrorType; EmptyTree } def success(macroImplRef: Tree) = { bindMacroImpl(macroDef, macroImplRef); macroImplRef } - if (!typer.checkFeature(macroDdef.pos, MacrosFeature, immediate = true)) { + if (!typer.checkFeature(macroDdef.pos, currentRun.runDefinitions.MacrosFeature, immediate = true)) { macroLogVerbose("typecheck terminated unexpectedly: language.experimental.macros feature is not enabled") fail() } else { -- cgit v1.2.3