summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bincompat-forward.whitelist.conf12
-rw-r--r--src/compiler/scala/tools/nsc/Global.scala7
-rw-r--r--src/compiler/scala/tools/nsc/Reporting.scala25
-rw-r--r--src/reflect/scala/reflect/internal/Reporting.scala31
-rw-r--r--src/reflect/scala/reflect/internal/Variances.scala2
-rw-r--r--src/reflect/scala/reflect/runtime/JavaUniverse.scala8
-rw-r--r--test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala7
7 files changed, 59 insertions, 33 deletions
diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf
index dbf0807999..30dac79974 100644
--- a/bincompat-forward.whitelist.conf
+++ b/bincompat-forward.whitelist.conf
@@ -242,6 +242,18 @@ filter {
{
matchName="scala.reflect.runtime.JavaUniverse.reporter"
problemName=MissingMethodProblem
+ },
+ {
+ matchName="scala.reflect.runtime.JavaUniverse$PerRunReporting"
+ problemName=MissingClassProblem
+ },
+ {
+ matchName="scala.reflect.runtime.JavaUniverse.currentRun"
+ problemName=MissingMethodProblem
+ },
+ {
+ matchName="scala.reflect.runtime.JavaUniverse.PerRunReporting"
+ problemName=MissingMethodProblem
}
]
}
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala
index a6fa3bf1dc..572e579aca 100644
--- a/src/compiler/scala/tools/nsc/Global.scala
+++ b/src/compiler/scala/tools/nsc/Global.scala
@@ -1045,7 +1045,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
def currentUnit: CompilationUnit = if (currentRun eq null) NoCompilationUnit else currentRun.currentUnit
def currentSource: SourceFile = if (currentUnit.exists) currentUnit.source else lastSeenSourceFile
def currentFreshNameCreator = currentUnit.fresh
- def currentReporting = currentRun.reporting
def isGlobalInitialized = (
definitions.isDefinitionsInitialized
@@ -1093,7 +1092,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** Don't want to introduce new errors trying to report errors,
* so swallow exceptions.
*/
- def supplementTyperState(errorMessage: String): String = try {
+ override def supplementTyperState(errorMessage: String): String = try {
val tree = analyzer.lastTreeToTyper
val sym = tree.symbol
val tpe = tree.tpe
@@ -1156,7 +1155,7 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** A Run is a single execution of the compiler on a set of units.
*/
- class Run extends RunContextApi {
+ class Run extends RunContextApi with RunReporting {
/** Have been running into too many init order issues with Run
* during erroneous conditions. Moved all these vals up to the
* top of the file so at least they're not trivially null.
@@ -1165,8 +1164,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
/** The currently compiled unit; set from GlobalPhase */
var currentUnit: CompilationUnit = NoCompilationUnit
- val reporting = new PerRunReporting
-
// used in sbt
def uncheckedWarnings: List[(Position, String)] = reporting.uncheckedWarnings
// used in sbt
diff --git a/src/compiler/scala/tools/nsc/Reporting.scala b/src/compiler/scala/tools/nsc/Reporting.scala
index 1b5a778235..9a20807145 100644
--- a/src/compiler/scala/tools/nsc/Reporting.scala
+++ b/src/compiler/scala/tools/nsc/Reporting.scala
@@ -18,24 +18,13 @@ import scala.collection.{ mutable, immutable }
trait Reporting extends scala.reflect.internal.Reporting { self: ast.Positions with CompilationUnits with scala.reflect.api.Symbols =>
def settings: Settings
- // == currentRun.reporting
- def currentReporting: PerRunReporting
-
- def supplementTyperState(errorMessage: String): String
-
// not deprecated yet, but a method called "error" imported into
// nearly every trait really must go. For now using globalError.
def error(msg: String) = globalError(msg)
- override def deprecationWarning(pos: Position, msg: String) = currentReporting.deprecationWarning(pos, msg)
- override def supplementErrorMessage(errorMessage: String) = currentReporting.supplementErrorMessage(errorMessage)
-
- // a new instance of this class is created for every Run (access the current instance via `currentReporting`)
- class PerRunReporting {
- // NOTE: scala.reflect.macros.Parsers#parse relies on everything related to reporting going through this def...
- // TODO: can we rework this to avoid the indirection/fragility?
- def reporter = Reporting.this.reporter
-
+ // a new instance of this class is created for every Run (access the current instance via `currentRun.reporting`)
+ protected def PerRunReporting = new PerRunReporting
+ class PerRunReporting extends PerRunReportingBase {
/** Collects for certain classes of warnings during this run. */
private class ConditionalWarning(what: String, option: Settings#BooleanSetting) {
val warnings = mutable.LinkedHashMap[Position, String]()
@@ -126,13 +115,5 @@ trait Reporting extends scala.reflect.internal.Reporting { self: ast.Positions w
if (incompleteHandled) incompleteHandler(pos, msg)
else reporter.error(pos, msg)
- /** Have we already supplemented the error message of a compiler crash? */
- private[this] var supplementedError = false
- def supplementErrorMessage(errorMessage: String): String =
- if (supplementedError) errorMessage
- else {
- supplementedError = true
- supplementTyperState(errorMessage)
- }
}
} \ No newline at end of file
diff --git a/src/reflect/scala/reflect/internal/Reporting.scala b/src/reflect/scala/reflect/internal/Reporting.scala
index 0670e9bd8e..423127803e 100644
--- a/src/reflect/scala/reflect/internal/Reporting.scala
+++ b/src/reflect/scala/reflect/internal/Reporting.scala
@@ -16,6 +16,32 @@ package internal
*/
trait Reporting { self : Positions =>
def reporter: Reporter
+ def currentRun: RunReporting
+
+ trait RunReporting {
+ val reporting: PerRunReporting = PerRunReporting
+ }
+
+ type PerRunReporting <: PerRunReportingBase
+ protected def PerRunReporting: PerRunReporting
+ abstract class PerRunReportingBase {
+ def deprecationWarning(pos: Position, msg: String): Unit
+
+ /** Have we already supplemented the error message of a compiler crash? */
+ private[this] var supplementedError = false
+ def supplementErrorMessage(errorMessage: String): String =
+ if (supplementedError) errorMessage
+ else {
+ supplementedError = true
+ supplementTyperState(errorMessage)
+ }
+
+ }
+
+ // overridden in Global
+ def supplementTyperState(errorMessage: String): String = errorMessage
+
+ def supplementErrorMessage(errorMessage: String) = currentRun.reporting.supplementErrorMessage(errorMessage)
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def inform(msg: String): Unit = inform(NoPosition, msg)
@@ -39,11 +65,6 @@ trait Reporting { self : Positions =>
def warning(pos: Position, msg: String) = reporter.warning(pos, msg)
@deprecatedOverriding("This forwards to the corresponding method in reporter -- override reporter instead", "2.11.2")
def globalError(pos: Position, msg: String) = reporter.error(pos, msg)
-
- def deprecationWarning(pos: Position, msg: String): Unit = warning(msg)
-
- /** Overridden when we know more about what was happening during a failure. */
- def supplementErrorMessage(msg: String): String = msg
}
import util.Position
diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala
index cfe2ad8b87..12b765b7a6 100644
--- a/src/reflect/scala/reflect/internal/Variances.scala
+++ b/src/reflect/scala/reflect/internal/Variances.scala
@@ -79,7 +79,7 @@ trait Variances {
// Unsound pre-2.11 behavior preserved under -Xsource:2.10
if (settings.isScala211 || sym.isOverridingSymbol) Invariant
else {
- deprecationWarning(sym.pos, s"Construct depends on unsound variance analysis and will not compile in scala 2.11 and beyond")
+ currentRun.reporting.deprecationWarning(sym.pos, s"Construct depends on unsound variance analysis and will not compile in scala 2.11 and beyond")
Bivariant
}
)
diff --git a/src/reflect/scala/reflect/runtime/JavaUniverse.scala b/src/reflect/scala/reflect/runtime/JavaUniverse.scala
index d846ef2cdd..fe39e1f245 100644
--- a/src/reflect/scala/reflect/runtime/JavaUniverse.scala
+++ b/src/reflect/scala/reflect/runtime/JavaUniverse.scala
@@ -27,6 +27,14 @@ class JavaUniverse extends InternalSymbolTable with JavaUniverseForce with Refle
protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit = log(msg)
}
+ // minimal Run to get Reporting wired
+ def currentRun = new RunReporting {}
+ class PerRunReporting extends PerRunReportingBase {
+ def deprecationWarning(pos: Position, msg: String): Unit = reporter.warning(pos, msg)
+ }
+ protected def PerRunReporting = new PerRunReporting
+
+
type TreeCopier = InternalTreeCopierOps
implicit val TreeCopierTag: ClassTag[TreeCopier] = ClassTag[TreeCopier](classOf[TreeCopier])
def newStrictTreeCopier: TreeCopier = new StrictTreeCopier
diff --git a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
index 6b87a99e6f..91868a5683 100644
--- a/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
+++ b/test/junit/scala/tools/nsc/symtab/SymbolTableForUnitTesting.scala
@@ -77,6 +77,13 @@ class SymbolTableForUnitTesting extends SymbolTable {
protected def info0(pos: Position, msg: String, severity: Severity, force: Boolean): Unit = println(msg)
}
+ // minimal Run to get Reporting wired
+ def currentRun = new RunReporting {}
+ class PerRunReporting extends PerRunReportingBase {
+ def deprecationWarning(pos: Position, msg: String): Unit = reporter.warning(pos, msg)
+ }
+ protected def PerRunReporting = new PerRunReporting
+
// Members declared in scala.reflect.internal.SymbolTable
def currentRunId: Int = 1
def log(msg: => AnyRef): Unit = println(msg)