summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2014-07-17 11:35:40 +0200
committerAdriaan Moors <adriaan.moors@typesafe.com>2014-07-17 15:51:13 +0200
commit474141f4271d97d082cc8d26c64273eccb5a9ff6 (patch)
treed75455b1789881d0619c8d38203fa11ba28eddb8
parent338cfff69ea5cbd91f0cbb8f29d690f2069c0a00 (diff)
downloadscala-474141f4271d97d082cc8d26c64273eccb5a9ff6.tar.gz
scala-474141f4271d97d082cc8d26c64273eccb5a9ff6.tar.bz2
scala-474141f4271d97d082cc8d26c64273eccb5a9ff6.zip
Reduce Context iface: inline complex forwarders.
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala10
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Typers.scala20
2 files changed, 19 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 965547d835..e4925b939e 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -1359,7 +1359,8 @@ trait Implicits {
if (Statistics.canEnable) Statistics.incCounter(inscopeImplicitHits)
}
if (result.isFailure) {
- val previousErrs = context.flushAndReturnBuffer()
+ val previousErrs = context.reportBuffer.errors
+ context.reportBuffer.clearAllErrors()
val failstart = if (Statistics.canEnable) Statistics.startTimer(oftypeFailNanos) else null
val succstart = if (Statistics.canEnable) Statistics.startTimer(oftypeSucceedNanos) else null
@@ -1371,7 +1372,7 @@ trait Implicits {
result = searchImplicit(implicitsOfExpectedType, isLocalToCallsite = false)
if (result.isFailure) {
- context.updateBuffer(previousErrs)
+ context.reportBuffer ++= previousErrs
if (Statistics.canEnable) Statistics.stopTimer(oftypeFailNanos, failstart)
} else {
if (Statistics.canEnable) Statistics.stopTimer(oftypeSucceedNanos, succstart)
@@ -1428,9 +1429,8 @@ trait Implicits {
// thus, start each type var off with a fresh for every typedImplicit
resetTVars()
// any previous errors should not affect us now
- context.flushBuffer()
-
- val res = typedImplicit(ii, ptChecked = false, isLocalToCallsite)
+ context.reportBuffer.clearAllErrors()
+ val res = typedImplicit(ii, ptChecked = false, isLocalToCallsite)
if (res.tree ne EmptyTree) List((res, tvars map (_.constr)))
else Nil
}
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
index 0bedaca4ee..44755c650c 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala
@@ -480,16 +480,20 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
@inline
final def typerWithLocalContext[T](c: Context)(f: Typer => T): T = {
val res = f(newTyper(c))
- if (c.hasErrors)
- context.updateBuffer(c.flushAndReturnBuffer())
+ val errors = c.reportBuffer.errors
+ if (errors.nonEmpty) {
+ c.reportBuffer.clearAllErrors()
+ context.reportBuffer ++= errors
+ }
res
}
@inline
final def withSavedContext[T](c: Context)(f: => T) = {
- val savedErrors = c.flushAndReturnBuffer()
+ val savedErrors = c.reportBuffer.errors
+ c.reportBuffer.clearAllErrors()
val res = f
- c.updateBuffer(savedErrors)
+ c.reportBuffer ++= savedErrors
res
}
@@ -702,14 +706,18 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper
SilentTypeError(context1.reportBuffer.errors: _*)
} else {
// If we have a successful result, emit any warnings it created.
- context1.flushAndIssueWarnings()
+ context1.reportBuffer.warnings foreach {
+ case (pos, msg) => reporter.warning(pos, msg)
+ }
+ context1.reportBuffer.clearAllWarnings()
SilentResultValue(result)
}
} else {
assert(context.bufferErrors || isPastTyper, "silent mode is not available past typer")
withSavedContext(context){
val res = op(this)
- val errorsToReport = context.flushAndReturnBuffer()
+ val errorsToReport = context.reportBuffer.errors
+ context.reportBuffer.clearAllErrors()
if (errorsToReport.isEmpty) SilentResultValue(res) else SilentTypeError(errorsToReport.head)
}
}