diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-04 08:56:39 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-04 08:56:39 -0700 |
commit | e9a696ce610c141a6a21f4201229ed52c1ccebc3 (patch) | |
tree | f25b031ee7a9838ddcccc259dfb6ad408abbb4e8 /src | |
parent | cb066cc6af2e836d66593d2fec56bc2c6a786d1a (diff) | |
parent | e6796eb516968c13957fc99954ec0a9862bb0111 (diff) | |
download | scala-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')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Infer.scala | 11 |
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) } |