summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-07-08 08:27:27 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-07-17 15:44:58 +0200
commit5895e10adb3ec3e711cd48a9d0f0f9095c7f8ab9 (patch)
tree823a665022ea7a6bcc90a9ccd91fe796544fec27 /src/compiler/scala/tools/nsc/typechecker/Contexts.scala
parent67651e220a6a4d1d1ee1004766d5b1e33fd46531 (diff)
downloadscala-5895e10adb3ec3e711cd48a9d0f0f9095c7f8ab9.tar.gz
scala-5895e10adb3ec3e711cd48a9d0f0f9095c7f8ab9.tar.bz2
scala-5895e10adb3ec3e711cd48a9d0f0f9095c7f8ab9.zip
Concretize diagnostics: one boolean suffices for now.
Once we get the next diagnostic, lets encapsulate them in an object, with a boolean flag for each one when it needs to trigger, and a nice message that should be presented to our delighted user. A list of Strings that is searched by contents is a bit fragile, and can't be very fast either.
Diffstat (limited to 'src/compiler/scala/tools/nsc/typechecker/Contexts.scala')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index aa2394897c..7cb2ad7ac5 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -265,8 +265,9 @@ trait Contexts { self: Analyzer =>
def defaultModeForTyped: Mode = if (inTypeConstructorAllowed) Mode.NOmode else Mode.EXPRmode
- /** These messages are printed when issuing an error */
- var diagnostic: List[String] = Nil
+ /** To enrich error messages involving default arguments.
+ When extending the notion, group diagnostics in an object. */
+ var diagUsedDefaults: Boolean = false
/** Saved type bounds for type parameters which are narrowed in a GADT. */
var savedTypeBounds: List[(Symbol, Type)] = List()
@@ -452,7 +453,7 @@ trait Contexts { self: Analyzer =>
// Fields that are directly propagated
c.variance = variance
- c.diagnostic = diagnostic
+ c.diagUsedDefaults = diagUsedDefaults
c.openImplicits = openImplicits
c.contextMode = contextMode // note: ConstructorSuffix, a bit within `mode`, is conditionally overwritten below.
c._reportBuffer = reportBuffer
@@ -532,16 +533,15 @@ trait Contexts { self: Analyzer =>
//
// Error and warning issuance
//
-
private def addDiagString(msg: String) = {
- val ds =
- if (diagnostic.isEmpty) ""
- else diagnostic.mkString("\n","\n", "")
- if (msg endsWith ds) msg else msg + ds
+ val diagUsedDefaultsMsg = "Error occurred in an application involving default arguments."
+ if (diagUsedDefaults && !(msg endsWith diagUsedDefaultsMsg)) msg + "\n" + diagUsedDefaultsMsg
+ else msg
}
private def unitError(pos: Position, msg: String): Unit =
- if (checking) onTreeCheckerError(pos, msg) else reporter.error(pos, msg)
+ if (checking) onTreeCheckerError(pos, msg)
+ else reporter.error(pos, msg)
@inline private def issueCommon(err: AbsTypeError, reportError: Boolean) {
// TODO: are errors allowed to have pos == NoPosition??