From b433bdba5aa7d8947032cc15454666c8a4a30115 Mon Sep 17 00:00:00 2001 From: Hubert Plociniczak Date: Sat, 18 Feb 2012 01:13:37 +0100 Subject: Closes #5497. Chain contexts by sharing the error buffer, unless you explicitly create a silent context. Review by @odersky --- src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/compiler') diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 740acbd10f..8586ebf0d4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -128,6 +128,8 @@ trait Contexts { self: Analyzer => var typingIndentLevel: Int = 0 def typingIndent = " " * typingIndentLevel + + var buffer: Set[AbsTypeError] = _ def enclClassOrMethod: Context = if ((owner eq NoSymbol) || (owner.isClass) || (owner.isMethod)) this @@ -146,7 +148,6 @@ trait Contexts { self: Analyzer => } private[this] var mode = 0 - private[this] val buffer = LinkedHashSet[AbsTypeError]() def errBuffer = buffer def hasErrors = buffer.nonEmpty @@ -161,7 +162,7 @@ trait Contexts { self: Analyzer => def setReportErrors() = mode = (ReportErrors | AmbiguousErrors) def setBufferErrors() = { - assert(bufferErrors || !hasErrors, "When entering the buffer state, context has to be clean. Current buffer: " + buffer) + //assert(bufferErrors || !hasErrors, "When entering the buffer state, context has to be clean. Current buffer: " + buffer) mode = BufferErrors } def setThrowErrors() = mode &= (~AllMask) @@ -226,6 +227,7 @@ trait Contexts { self: Analyzer => c.checking = this.checking c.retyping = this.retyping c.openImplicits = this.openImplicits + c.buffer = if (this.buffer == null) LinkedHashSet[AbsTypeError]() else this.buffer // need to initialize registerContext(c.asInstanceOf[analyzer.Context]) debuglog("[context] ++ " + c.unit + " / " + tree.summaryString) c @@ -266,6 +268,7 @@ trait Contexts { self: Analyzer => val c = make(newtree) c.setBufferErrors() c.setAmbiguousErrors(reportAmbiguousErrors) + c.buffer = new LinkedHashSet[AbsTypeError]() c } @@ -309,6 +312,7 @@ trait Contexts { self: Analyzer => unit.error(pos, if (checking) "\n**** ERROR DURING INTERNAL CHECKING ****\n" + msg else msg) def issue(err: AbsTypeError) { + if (settings.debug.value) println("issue error: " + err.errMsg) if (reportErrors) unitError(err.errPos, addDiagString(err.errMsg)) else if (bufferErrors) { buffer += err } else throw new TypeError(err.errPos, err.errMsg) -- cgit v1.2.3