Fix -Yrangepos. Unlike other settings, it requires that a mixin be added to Global.

This commit is contained in:
Lex Spoon 2012-11-30 17:29:01 -05:00 committed by Mark Harrah
parent c1051f1f1e
commit b7250bb528
1 changed files with 12 additions and 5 deletions

View File

@ -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 = {