Permalink
Browse files

De-duplication in Contexts.

Friends don't let friends cut and paste.
  • Loading branch information...
1 parent cf18d87 commit 1d7430c7d574f02ea88ed8e1b5394e8986be5618 @paulp paulp committed Apr 30, 2012
Showing with 12 additions and 14 deletions.
  1. +12 −14 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

0 comments on commit 1d7430c

Please sign in to comment.