summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
diff options
context:
space:
mode:
authorLukas Rytz <lukas.rytz@epfl.ch>2009-07-01 11:10:23 +0000
committerLukas Rytz <lukas.rytz@epfl.ch>2009-07-01 11:10:23 +0000
commit6cee8d5837b77e5a3ba18affb802fbb466f004ee (patch)
tree6af7a9217ff5dba47563c7e4d3f0c0e30d256ca5 /src/compiler/scala/tools/nsc/typechecker/Contexts.scala
parent7ac2fc34f7fabf846b4d5ebecf26eb63d123ab4b (diff)
downloadscala-6cee8d5837b77e5a3ba18affb802fbb466f004ee.tar.gz
scala-6cee8d5837b77e5a3ba18affb802fbb466f004ee.tar.bz2
scala-6cee8d5837b77e5a3ba18affb802fbb466f004ee.zip
added "diagnostic" to context.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 5b98b070ce..114525aabc 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -110,6 +110,7 @@ trait Contexts { self: Analyzer =>
var returnsSeen = false // for method context: were returns encountered?
var reportAmbiguousErrors = false
var reportGeneralErrors = false
+ var diagnostic: List[String] = Nil // these messages are printed when issuing an error
var implicitsEnabled = false
var checking = false
var retyping = false
@@ -208,6 +209,7 @@ trait Contexts { self: Analyzer =>
c.imports = imports
c.reportAmbiguousErrors = this.reportAmbiguousErrors
c.reportGeneralErrors = this.reportGeneralErrors
+ c.diagnostic = this.diagnostic
c.implicitsEnabled = this.implicitsEnabled
c.checking = this.checking
c.retyping = this.retyping
@@ -291,8 +293,12 @@ trait Contexts { self: Analyzer =>
c
}
+ private def diagString =
+ if (diagnostic.isEmpty) ""
+ else diagnostic.mkString("\n","\n", "")
+
def error(pos: Position, err: Error) {
- val msg = err.getMessage()
+ val msg = err.getMessage() + diagString
if (reportGeneralErrors)
unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
else
@@ -300,10 +306,11 @@ trait Contexts { self: Analyzer =>
}
def error(pos: Position, msg: String) {
+ val msg1 = msg + diagString
if (reportGeneralErrors)
- unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
+ unit.error(pos, if (checking) "**** ERROR DURING INTERNAL CHECKING ****\n" + msg1 else msg1)
else
- throw new TypeError(pos, msg)
+ throw new TypeError(pos, msg1)
}
def warning(pos: Position, msg: String) {