From b7250bb52827b3d270e9659072dbbaa344980180 Mon Sep 17 00:00:00 2001 From: Lex Spoon Date: Fri, 30 Nov 2012 17:29:01 -0500 Subject: [PATCH] Fix -Yrangepos. Unlike other settings, it requires that a mixin be added to Global. --- compile/interface/CompilerInterface.scala | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/compile/interface/CompilerInterface.scala b/compile/interface/CompilerInterface.scala index 2922360e7..d9d190dc8 100644 --- a/compile/interface/CompilerInterface.scala +++ b/compile/interface/CompilerInterface.scala @@ -6,6 +6,7 @@ package xsbt import xsbti.{AnalysisCallback,Logger,Problem,Reporter,Severity} import xsbti.compile._ import scala.tools.nsc.{backend, io, reporters, symtab, util, Phase, Global, Settings, SubComponent} +import scala.tools.nsc.interactive.RangePositions import backend.JavaPlatform import scala.tools.util.PathResolver import symtab.SymbolLoaders @@ -72,7 +73,6 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial val command = Command(args.toList, settings) private[this] val dreporter = DelegatingReporter(settings, initialLog.reporter) try { - compiler // force compiler internal structures if(!noErrors(dreporter)) { dreporter.printSummary() handleErrors(dreporter, initialLog.logger) @@ -138,12 +138,19 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial if(!warnings.isEmpty) compiler.logUnreportedWarnings(warnings.map(cw => ("" /*cw.what*/, cw.warnings.toList))) } - object compiler extends CallbackGlobal(command.settings, dreporter, output) + + val compiler: Compiler = { + if (command.settings.Yrangepos.value) + new Compiler() with RangePositions + else + new Compiler() + } + class Compiler extends CallbackGlobal(command.settings, dreporter, output) { object dummy // temporary fix for #4426 object sbtAnalyzer extends { - val global: compiler.type = compiler + val global: Compiler.this.type = Compiler.this val phaseName = Analyzer.name val runsAfter = List("jvm") override val runsBefore = List("terminal") @@ -157,7 +164,7 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial } object apiExtractor extends { - val global: compiler.type = compiler + val global: Compiler.this.type = Compiler.this val phaseName = API.name val runsAfter = List("typer") override val runsBefore = List("erasure") @@ -254,7 +261,7 @@ private final class CachedCompiler0(args: Array[String], output: Output, initial final class PlatformImpl extends JavaPlatform { - val global: compiler.type = compiler + val global: Compiler.this.type = Compiler.this // This can't be overridden to provide a ClassPathCell, so we have to fix it to the initial classpath // This is apparently never called except by rootLoader, so we can return the default and warn if someone tries to use it. override lazy val classPath = {