summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2012-04-30 09:22:12 -0700
committerPaul Phillips <paulp@improving.org>2012-04-30 09:40:49 -0700
commit1d7430c7d574f02ea88ed8e1b5394e8986be5618 (patch)
treed4b6eb13a11fb29bf9471b038ed99139857d0a48
parentcf18d879d3f43d5a0c15c5c0af72f88c25605a08 (diff)
downloadscala-1d7430c7d574f02ea88ed8e1b5394e8986be5618.tar.gz
scala-1d7430c7d574f02ea88ed8e1b5394e8986be5618.tar.bz2
scala-1d7430c7d574f02ea88ed8e1b5394e8986be5618.zip
De-duplication in Contexts.
Friends don't let friends cut and paste.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Contexts.scala26
1 files changed, 12 insertions, 14 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
index 4584ba032d..0924789948 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala
@@ -354,32 +354,30 @@ trait Contexts { self: Analyzer =>
private def unitError(pos: Position, msg: String) =
unit.error(pos, if (checking) "\n**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg)
-
- def issue(err: AbsTypeError) {
+
+ @inline private def issueCommon(err: AbsTypeError)(pf: PartialFunction[AbsTypeError, Unit]) {
debugwarn("issue error: " + err.errMsg)
if (settings.Yissuedebug.value) (new Exception).printStackTrace()
- if (reportErrors) unitError(err.errPos, addDiagString(err.errMsg))
+ if (pf isDefinedAt err) pf(err)
else if (bufferErrors) { buffer += err }
else throw new TypeError(err.errPos, err.errMsg)
}
+ def issue(err: AbsTypeError) {
+ issueCommon(err) { case _ if reportErrors =>
+ unitError(err.errPos, addDiagString(err.errMsg))
+ }
+ }
+
def issueAmbiguousError(pre: Type, sym1: Symbol, sym2: Symbol, err: AbsTypeError) {
- debugwarn("issue ambiguous error: " + err.errMsg)
- if (settings.Yissuedebug.value) (new Exception).printStackTrace()
- if (ambiguousErrors) {
+ issueCommon(err) { case _ if ambiguousErrors =>
if (!pre.isErroneous && !sym1.isErroneous && !sym2.isErroneous)
unitError(err.errPos, err.errMsg)
- } else if (bufferErrors) { buffer += err }
- else throw new TypeError(err.errPos, err.errMsg)
+ }
}
def issueAmbiguousError(err: AbsTypeError) {
- debugwarn("issue ambiguous error: " + err.errMsg)
- if (settings.Yissuedebug.value) (new Exception).printStackTrace()
- if (ambiguousErrors)
- unitError(err.errPos, addDiagString(err.errMsg))
- else if (bufferErrors) { buffer += err }
- else throw new TypeError(err.errPos, err.errMsg)
+ issueCommon(err) { case _ if ambiguousErrors => unitError(err.errPos, addDiagString(err.errMsg)) }
}
// TODO remove