summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@gmail.com>2012-07-03 13:29:05 +0200
committerHubert Plociniczak <hubert.plociniczak@gmail.com>2012-07-03 13:32:39 +0200
commite6796eb516968c13957fc99954ec0a9862bb0111 (patch)
tree790fee4776fdcb84a41caccc2ce2a2caa4373f27
parent12b72485d873534bcce0b0564c99d89d6b1aa964 (diff)
downloadscala-e6796eb516968c13957fc99954ec0a9862bb0111.tar.gz
scala-e6796eb516968c13957fc99954ec0a9862bb0111.tar.bz2
scala-e6796eb516968c13957fc99954ec0a9862bb0111.zip
Better explanation for SI-5969.
The comment should now better reflect the joys of tryTwice as discussed during the code review.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index e1aabb5469..d1974a058c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1612,8 +1612,12 @@ trait Infer {
val saved = context.state
var fallback = false
context.setBufferErrors()
- // Need to test first attempt with an empty buffer.
- // Otherwise, any previous errors will get lost.
+ // 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))