diff options
author | Paul Phillips <paulp@improving.org> | 2012-12-20 12:58:03 -0800 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2012-12-20 14:47:50 -0800 |
commit | 106ca1b6767c60912b6726eeb1d435f6e22a025f (patch) | |
tree | c3c4c9a0d988720973b69f196c04e781e6e3f767 /src/compiler/scala/tools/nsc/Global.scala | |
parent | a313fa1d2c03d49fa7bc2a5f9c1886c48e08aab6 (diff) | |
parent | 9ddb4cf41f9832e46fa1109d96fc6708c4586c53 (diff) | |
download | scala-106ca1b6767c60912b6726eeb1d435f6e22a025f.tar.gz scala-106ca1b6767c60912b6726eeb1d435f6e22a025f.tar.bz2 scala-106ca1b6767c60912b6726eeb1d435f6e22a025f.zip |
Merge remote-tracking branch 'origin/2.10.x' into merge-2.10.x
* origin/2.10.x: (31 commits)
Implicit vars should have non-implicit setters.
Deprecate `scala.tools.nsc.Phases` because it's dead-code.
scaladoc Template: remove duplicate code and several usages of Option.get.
adds scala-reflect.jar to MIMA in ant
Test showing the absence of a forward reference
update mailmap
Remove dead code from `Global`.
Cleanup MemberLookup. Better explain ambiguous link targets.
typedIdent no longer destroys attachments
fixes incorrect handling of Annotated in lazy copier
simplifies checkBounds
Recurse into instantiations when stripping type vars.
Extract base scaladoc functionality for the IDE.
Expand pattern match position tests.
SI-6288 Remedy ill-positioned extractor binding.
SI-6288 Fix positioning of label jumps
SI-6288 Position argument of unapply
Fixes SI-6758: force LazyAnnnotationInfo for DefDef and TypeDef
SI-6795 Simplify errors related to "abstract override" on type members
SI-6795 Adds negative check for "abstract override" on types in traits
...
Conflicts:
.mailmap
src/compiler/scala/tools/nsc/Global.scala
src/compiler/scala/tools/nsc/ast/DocComments.scala
src/compiler/scala/tools/nsc/doc/base/CommentFactoryBase.scala
src/compiler/scala/tools/nsc/doc/html/page/Source.scala
src/compiler/scala/tools/nsc/doc/html/page/Template.scala
src/compiler/scala/tools/nsc/doc/model/LinkTo.scala
src/compiler/scala/tools/nsc/doc/model/MemberLookup.scala
src/compiler/scala/tools/nsc/doc/model/diagram/DiagramFactory.scala
src/compiler/scala/tools/nsc/transform/SpecializeTypes.scala
src/compiler/scala/tools/nsc/typechecker/Typers.scala
src/reflect/scala/reflect/runtime/JavaMirrors.scala
test/scaladoc/run/links.scala
Diffstat (limited to 'src/compiler/scala/tools/nsc/Global.scala')
-rw-r--r-- | src/compiler/scala/tools/nsc/Global.scala | 75 |
1 files changed, 41 insertions, 34 deletions
diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index 34d5d10cbf..75f38c7d67 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -284,7 +284,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) log(msg) } - def logThrowable(t: Throwable): Unit = globalError(throwableAsString(t)) + @deprecated("Renamed to reportThrowable", "2.10.1") + def logThrowable(t: Throwable): Unit = reportThrowable(t) + def reportThrowable(t: Throwable): Unit = globalError(throwableAsString(t)) override def throwableAsString(t: Throwable) = util.stackTraceString(t) // ------------ File interface ----------------------------------------- @@ -709,7 +711,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /* The set of phase objects that is the basis for the compiler phase chain */ protected lazy val phasesSet = new mutable.HashSet[SubComponent] protected lazy val phasesDescMap = new mutable.HashMap[SubComponent, String] withDefaultValue "" - private lazy val phaseTimings = new Phases.TimingModel // tracking phase stats protected def addToPhasesSet(sub: SubComponent, descr: String) { phasesSet += sub @@ -1038,37 +1039,41 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /** Don't want to introduce new errors trying to report errors, * so swallow exceptions. */ - override def supplementErrorMessage(errorMessage: String): String = try { - val tree = analyzer.lastTreeToTyper - val sym = tree.symbol - val tpe = tree.tpe - val enclosing = lastSeenContext.enclClassOrMethod.tree - - val info1 = formatExplain( - "while compiling" -> currentSource.path, - "during phase" -> ( if (globalPhase eq phase) phase else "global=%s, enteringPhase=%s".format(globalPhase, phase) ), - "library version" -> scala.util.Properties.versionString, - "compiler version" -> Properties.versionString, - "reconstructed args" -> settings.recreateArgs.mkString(" ") - ) - val info2 = formatExplain( - "last tree to typer" -> tree.summaryString, - "symbol" -> Option(sym).fold("null")(_.debugLocationString), - "symbol definition" -> Option(sym).fold("null")(_.defString), - "tpe" -> tpe, - "symbol owners" -> ownerChainString(sym), - "context owners" -> ownerChainString(lastSeenContext.owner) - ) - val info3: List[String] = ( - ( List("== Enclosing template or block ==", nodePrinters.nodeToString(enclosing).trim) ) - ++ ( if (tpe eq null) Nil else List("== Expanded type of tree ==", typeDeconstruct.show(tpe)) ) - ++ ( if (!settings.debug.value) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) ) - ++ ( List(errorMessage) ) - ) - - ("\n" + info1) :: info2 :: info3 mkString "\n\n" - } - catch { case x: Exception => errorMessage } + override def supplementErrorMessage(errorMessage: String): String = + if (currentRun.supplementedError) errorMessage + else try { + val tree = analyzer.lastTreeToTyper + val sym = tree.symbol + val tpe = tree.tpe + val enclosing = lastSeenContext.enclClassOrMethod.tree + + val info1 = formatExplain( + "while compiling" -> currentSource.path, + "during phase" -> ( if (globalPhase eq phase) phase else "global=%s, enteringPhase=%s".format(globalPhase, phase) ), + "library version" -> scala.util.Properties.versionString, + "compiler version" -> Properties.versionString, + "reconstructed args" -> settings.recreateArgs.mkString(" ") + ) + val info2 = formatExplain( + "last tree to typer" -> tree.summaryString, + "symbol" -> Option(sym).fold("null")(_.debugLocationString), + "symbol definition" -> Option(sym).fold("null")(_.defString), + "tpe" -> tpe, + "symbol owners" -> ownerChainString(sym), + "context owners" -> ownerChainString(lastSeenContext.owner) + ) + val info3: List[String] = ( + ( List("== Enclosing template or block ==", nodePrinters.nodeToString(enclosing).trim) ) + ++ ( if (tpe eq null) Nil else List("== Expanded type of tree ==", typeDeconstruct.show(tpe)) ) + ++ ( if (!settings.debug.value) Nil else List("== Current unit body ==", nodePrinters.nodeToString(currentUnit.body)) ) + ++ ( List(errorMessage) ) + ) + + currentRun.supplementedError = true + + ("\n" + info1) :: info2 :: info3 mkString "\n\n" + } + catch { case x: Exception => errorMessage } /** The id of the currently active run */ @@ -1122,6 +1127,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) /** Has any macro expansion used a fallback during this run? */ var seenMacroExpansionsFallingBack = false + /** Have we already supplemented the error message of a compiler crash? */ + private[nsc] final var supplementedError = false + private val unitbuf = new mutable.ListBuffer[CompilationUnit] val compiledFiles = new mutable.HashSet[String] @@ -1478,7 +1486,6 @@ class Global(var currentSettings: Settings, var reporter: Reporter) // progress update informTime(globalPhase.description, startTime) - phaseTimings(globalPhase) = currentTime - startTime val shouldWriteIcode = ( (settings.writeICode.isSetByUser && (settings.writeICode containsPhase globalPhase)) || (!settings.Xprint.doAllPhases && (settings.Xprint containsPhase globalPhase) && runIsAtOptimiz) |