summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@epfl.ch>2012-07-04 08:56:39 -0700
committerAdriaan Moors <adriaan.moors@epfl.ch>2012-07-04 08:56:39 -0700
commite9a696ce610c141a6a21f4201229ed52c1ccebc3 (patch)
treef25b031ee7a9838ddcccc259dfb6ad408abbb4e8 /src/compiler
parentcb066cc6af2e836d66593d2fec56bc2c6a786d1a (diff)
parente6796eb516968c13957fc99954ec0a9862bb0111 (diff)
downloadscala-e9a696ce610c141a6a21f4201229ed52c1ccebc3.tar.gz
scala-e9a696ce610c141a6a21f4201229ed52c1ccebc3.tar.bz2
scala-e9a696ce610c141a6a21f4201229ed52c1ccebc3.zip
Merge pull request #814 from hubertp/issue/5969
Closes SI-5969.
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index e99c31374e..960c210649 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1614,6 +1614,13 @@ trait Infer {
val saved = context.state
var fallback = false
context.setBufferErrors()
+ // We cache the current buffer because it is impossible to
+ // distinguish errors that occurred before entering tryTwice
+ // and our first attempt in 'withImplicitsDisabled'. If the
+ // first attempt fails we try with implicits on *and* clean
+ // buffer but that would also flush any pre-tryTwice valid
+ // errors, hence some manual buffer tweaking is necessary.
+ val errorsToRestore = context.flushAndReturnBuffer()
try {
context.withImplicitsDisabled(infer(false))
if (context.hasErrors) {
@@ -1627,8 +1634,10 @@ trait Infer {
case ex: TypeError => // recoverable cyclic references
context.restoreState(saved)
if (!fallback) infer(true) else ()
+ } finally {
+ context.restoreState(saved)
+ context.updateBuffer(errorsToRestore)
}
- context.restoreState(saved)
}
else infer(true)
}